nasm in c - trouble writing c functions in nasm

This is the code:

bits 32
extern printf

segment .data
   RSIZE db 12
   INTSIZE db 4
   CHARSIZE db 1

segment .text
   global _printRecords

   mov EBP,ESP
   mov EDX,[EBP+8]      ; *R
   mov ECX,[EBP+12]     ; num_recs
   dec ECX              ; loop prep
   mov EBX,[EBP+16]     ; sizeof(R)
   xor EAX,EAX

   cmp EAX,ECX
   je loop_end
   push EDX
   call printf
   add ESP,4
   add EDX,EBX
   jmp loop_end

   mov ESP,EBP

// record_cl.h
// A definition of the Record class
// John Stewart

#include <iostream>
#include <string>
using namespace std;

#ifndef RECORD_CL_H
#define RECORD_CL_H

class Record {
      int Id;
      int Age;
      int Sex;


A command-line program to search Records
John Stewart
Last modified: 12/3/2003

#include <iostream>
#include <cstdio>
#include <string>
#include <fstream>
#include "record_cl.h"
using namespace std;

int numRecords (string);
void loadData (string, int, Record []);
void printRecords (Record [], int, int);
bool searchRecord (Record [], int, int);

int main () {
   string fn = "rec_data.txt";
   int num_recs = numRecords(fn);
   int s_age = 0;
   bool found_one = false;

   Record *R;
   Record *S;
   R = new Record[num_recs];
   loadData(fn, num_recs, R);
   printRecords (R, num_recs, sizeof(S));

   cout << "Enter search age: ";
   cin >> s_age;
   found_one = searchRecord(R, num_recs, s_age);

   delete [] R;

int numRecords (string fil) {
   ifstream file("rec_data.txt");
   int num;
   file >> num;

void loadData (string fn, int num, Record* rec) {
   ifstream file("rec_data.txt");
   file >> rec[0].Id;
   for (int i = 0; i < num; i++) {
      file >> rec[i].Id;
      file >> rec[i].Age;
      file >> rec[i].Sex;


bits 32
extern printf

segment .data
   RSIZ db 12
   NFOUND db "No match found",0
   FOUND db "User ID: %d",0xA,"Age: %d","Sex: %s",0xA,0xA,0

segment .text
   global _searchRecord

   mov EBP,ESP

   mov ESI,[EBP+8]         ; *R
   mov EDX,[ESI]
   xor EAX,EAX

   cmp EAX,[EBP+12]        ; [EBP+12] = num_recs
   je loop_end
   add EDX,4
   cmp EDX,[EBP+16]      ; [EBP+16] = s_age
   je print_it
r: add EDX,RSIZ
   sub EDX,4

   inc EAX
   jmp loop_start

   push dword [EDX]
   push dword [EDX+4]
   push dword [EDX+8]
   push FOUND
   call printf
   add ESP,16
   jmp r

   mov ESP,EBP
   mov EAX,1

record_search: searchRecord.o printRecords.o record_search.o
      g++ -o record_search searchRecord.o printRecords.o record_search.o
record_search.o: record_search.cpp
      g++ -c record_search.cpp
searchRecord.o: searchRecord.asm
      nasm -f elf searchRecord.asm
printRecords.o: printRecords.asm
      nasm -f elf printRecords.asm
      rm -f *~
      rm -f *.o
      rm -f record_search
      make clean

Here is the linker error:
record_search.o(.text+0x148): In function `main':
: undefined reference to `printRecords(Record*, int, int)'
record_search.o(.text+0x185): In function `main':
: undefined reference to `searchRecord(Record*, int, int)'
collect2: ld returned 1 exit status
make[1]: *** [record_search] Error 1
make[1]: Leaving directory `/home/stewart/project2'
make: *** [all] Error 2

I know there are other bugs, but this one eludes me.  I prototyped the functions, and coded them in assembly, and compiled the asm before the .c, and no go.  Why is this error being generated?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I'm not familiar with g++ or NASM, but it looks like you're declaring the entry point _printRecords but referring to printRecords.  Does g++ prepend the _?

same for _searchRecord
stubuf612Author Commented:
Nope, same compile error.
extern void printRecords (Record [], int, int);
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

stubuf612Author Commented:
nope.... same error
Given my lack of familiarity with these, anything else is pure speculation.  

All I can think of now is bypassing make and doing a manual link (make generating a flakey link?, yeah, sure)
>: undefined reference to `printRecords(Record*, int, int)'
>record_search.o(.text+0x185): In function `main':
>: undefined reference to `searchRecord(Record*, int, int)'
>collect2: ld returned 1 exit status

Linker was not able to locate definitions for the above mentioned functions .. i.e. while you have declared the functions, they have not been defined
stubuf612Author Commented:
well.... no... because I defined them in printRecords.asm and searchRecord.asm!!!
stubuf612Author Commented:
perhaps incorrectly, but still, they are defined in those asm files (the whole point)
stubuf612Author Commented:
Ah.... I've discovered the answer:

 extern "C" void printRecords (Record [], int, int);

That language type specification was the trick, but now a segmentation fault... argh!
run it through gdb

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
If you wish to, you can post in community support and seek refund for this question.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.