LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Linking without gcc, but with ld (http://www.linuxquestions.org/questions/programming-9/linking-without-gcc-but-with-ld-19426/)

gluon 04-25-2002 07:09 AM

Linking without gcc, but with ld
 
Hi all,

My final projet in my school is a study about the efficiency of the GNU tools (!!!). My question is directly related to one of these tools, ld :

I have a program, prog.c, which uses two libraries, lib01.c and lib02.c, which are header'd by lib01.h and lib02.h.

I produced the object files by gcc -c lib01.c lib02.c prog.c, which gave me lib01.o, lib02.o and prog.o.

I know that if I do a gcc lib01.o lib02.o prog.o -o my_prog, it will give an executable program, BUT I want that program to be linked WITHOUT gcc, but with ld !

Does anyone know how to do that ? I tried
ld -o my_prog prog.o lib01.o lib02.o -lc
but it says
ld: warning: cannot find entry symbol _start; defaulting to 0000000008048190

Thanks in advance !

CU, Gluon

kervin 05-19-2002 02:45 PM

compile with gcc -v to see exactly how gcc links your program. This should tell you what flags you need to link with on your platform.

gluon 05-29-2002 03:01 AM

Hi kervin,

Thanks for your advise ! I managed to go on with that work...

CU, gluon

sakeeb 05-29-2002 05:11 AM

use -e option with ld
ld -e main prog.o lib1.o lib2.o


All times are GMT -5. The time now is 09:53 AM.