When I link against libc (using ld file.o -lc), a.out doesn't work. I can't execute it with ./a.out (no such file or directory), bash a.out (cannot execute binary file), and trying ldd a.out gives me «no such file or directory» too.
What am I doing wrong? inb4 “using assembly”
>>1
You fool, bash runs shell scripts not executables!
There's the assembler and the linker step. Find in which the error occurs, give us a better description of what went wrong and which messages you got for error feedback.
Name:
Anonymous2009-09-12 17:22
>>2
You're right, I'm ashamed. It's just some advice I found while searching through the Internet a bit.
I'm pretty sure that something goes wrong with the linking.
I tried one of my earlier exercises, which doesn't use any external libraries. a.out from ld hw64.o works fine; a.out from ld hw64.o -lc gives me the same error when I try to run it.
And I don't get any error messages during assembling and linking.
Name:
Anonymous2009-09-12 17:36
Also, just checked, when I don't link it using ld but just run gcc printf.o, everything works fine. Now trying to figure out which of those options I need to use.
disregard this thread, I decided to just change my _start to main and use gcc.
still, if anyone knows the reason using ld the way I did doesn't work, I'd appreciate your input.
Name:
Anonymous2009-09-13 3:28
Link with the startup objects.
Name:
Anonymous2009-09-13 5:14
Put in the header yourself and build a flat binary.
Name:
Anonymous2009-09-13 13:41
>>1
yeah i had that problem before. i fixed it by linking again libc.a instead of libc.so.
Name:
Anonymous2009-09-13 17:11
>>8
You've statically linked against the standard C library? HIBT?
Name:
Anonymous2009-09-14 7:25
>>9
no. Static linking will only pull in the needed functions so it's not a big deal - It's not your binary will have a whole copy of libc within it.