Page 1 of 1

ld problem, help needed

Posted: Wed Sep 11, 2002 11:01 am
by Ozguxxx
Hi everybody, I am continuning my question series with a very very stupid one. I am trying to write a very simple program with djgpp, ld and nasm.


inside stringExp.asm:

[GLOBAL _name]

_name db 'Ozgun Harmanci',0

//////////////////////////////////////////////////////////////////

inside stringExp.c:

#include "stdio.h"

extern char name[];


int main(void)
{
   printf("%s", name);
   return 0;
}

I think this program should write Ozgun Harmanci onto screen.

However, when I compile and link these as:
nasm -f aout -o stringa.o stringExp.asm (This is OK)

gcc -c stringExp.c -o stringc.o (This is also OK)

ld -o string.exe stringa.o stringc.o

When ld is executed it gives 2 errors telling that there are undefined references to printf and name inside stringc.o

I know that this is a veryu simple mistake but I am newbie in object files and etc., so ;D. Thanx in advance for any advices...

Re:ld problem, help needed

Posted: Wed Sep 11, 2002 11:56 am
by Whatever5k
Remove the underscore(s) at name and try again

Re:ld problem, help needed

Posted: Wed Sep 11, 2002 12:50 pm
by Ozguxxx
No way, it still gives the same errors. ???

Re:ld problem, help needed

Posted: Wed Sep 11, 2002 1:27 pm
by Tom
did you use "extern" in the NASM and C modules?

Re:ld problem, help needed

Posted: Wed Sep 11, 2002 1:47 pm
by Tom
just saw that :o sorry ( I read to fast )