Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 04-25-2002, 07:09 AM   #1
Registered: Jun 2001
Location: Switzerland
Distribution: SuSE 8.[012], Gentoo
Posts: 42

Rep: Reputation: 15
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
Old 05-19-2002, 02:45 PM   #2
Registered: Jan 2002
Location: Melbourne, FL.
Distribution: redhat
Posts: 168

Rep: Reputation: 30
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.
Old 05-29-2002, 03:01 AM   #3
Registered: Jun 2001
Location: Switzerland
Distribution: SuSE 8.[012], Gentoo
Posts: 42

Original Poster
Rep: Reputation: 15
Hi kervin,

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

CU, gluon
Old 05-29-2002, 05:11 AM   #4
Registered: Apr 2002
Posts: 270

Rep: Reputation: 31
use -e option with ld
ld -e main prog.o lib1.o lib2.o


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
linking problem with gcc tokernizer Programming 1 11-19-2005 12:56 PM
Question about GCC linking procedures... vinculum Programming 3 09-26-2005 08:20 AM
gcc linking: undefined reference to just about everything shabbychef Programming 7 09-09-2005 08:42 PM
gcc linking error. ugenn Linux - Software 0 01-22-2003 11:18 PM
Linking when using gcc/f2c combination? chemspecialist Programming 0 05-17-2001 12:40 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:21 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration