ld problem, help needed

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Ozguxxx

ld problem, help needed

Post 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...
Whatever5k

Re:ld problem, help needed

Post by Whatever5k »

Remove the underscore(s) at name and try again
Ozguxxx

Re:ld problem, help needed

Post by Ozguxxx »

No way, it still gives the same errors. ???
Tom

Re:ld problem, help needed

Post by Tom »

did you use "extern" in the NASM and C modules?
Tom

Re:ld problem, help needed

Post by Tom »

just saw that :o sorry ( I read to fast )
Post Reply