This is my code, d.c uses function hello defined at callee.c.
Function hello is provide as static library, libcallee.a.
orange@orange-Rev-1-0:~/d$ ar -r libcallee.a callee.o
When linking libcallee.a, excute command like this, gcc failes.
orange@orange-Rev-1-0:~/d$ gcc -o d -lcallee -L. d.o
d.o: In function `main':
d.c:(.text+0xa): undefined reference to `hello'
collect2: ld returns 1
However, if you put the argument '-lcallee' at the end of the command, gcc succeeds.
orange@orange-Rev-1-0:~/d$ gcc -o d -L. d.o -lcallee
I dont't know why, I think this may be a bug.
Version of gcc I use is 4.6.2
No, not a bug, its meant to work that way, please consult the binutils linker manual.
Log in to post a comment.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.