public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] linking with ld or gcc?
@ 2006-11-05 15:47 Peter Volkov (pva)
  2006-11-05 16:25 ` Harald van Dijk
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Volkov (pva) @ 2006-11-05 15:47 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 728 bytes --]

Hello.

Short question: What shall we use to link libraries/programs: gcc or ld?
Why?

A bit longer story: I have a problem during linking of wepattack on
amd64 systems. Linking stage issues warning:

$ x86_64-pc-linux-gnu-ld  -o wepattack wepattack.o rc4.o wepfilter.o
log.o modes.o misc.o verify.o keygen.o -lpcap -lz -lcrypto
ld: warning: cannot find entry symbol _start; defaulting to
0000000000400e10

And resulted file is not executable. In google I found the most of
tutorials/howtos suggest to link with gcc but some programs still use
LD. From ld man page it's clear that it should link the program but this
is not working. So what is the right way to do that? Why?

Thank you for your time,
Peter.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [gentoo-dev] linking with ld or gcc?
  2006-11-05 15:47 [gentoo-dev] linking with ld or gcc? Peter Volkov (pva)
@ 2006-11-05 16:25 ` Harald van Dijk
  2006-12-08 17:41   ` Andreas Vinsander
  0 siblings, 1 reply; 4+ messages in thread
From: Harald van Dijk @ 2006-11-05 16:25 UTC (permalink / raw
  To: gentoo-dev

On Sun, Nov 05, 2006 at 06:47:07PM +0300, Peter Volkov (pva) wrote:
> Hello.
> 
> Short question: What shall we use to link libraries/programs: gcc or ld?
> Why?
> 
> A bit longer story: I have a problem during linking of wepattack on
> amd64 systems. Linking stage issues warning:
> 
> $ x86_64-pc-linux-gnu-ld  -o wepattack wepattack.o rc4.o wepfilter.o
> log.o modes.o misc.o verify.o keygen.o -lpcap -lz -lcrypto
> ld: warning: cannot find entry symbol _start; defaulting to
> 0000000000400e10
> 
> And resulted file is not executable. In google I found the most of
> tutorials/howtos suggest to link with gcc but some programs still use
> LD. From ld man page it's clear that it should link the program but this
> is not working. So what is the right way to do that? Why?

Link using gcc unless your program is a very special case. _start is defined
in /usr/lib/crt1.o (may be slightly different on amd64), and that as well as
other object files typically required by every program will be pulled in by
gcc.
-- 
gentoo-dev@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [gentoo-dev] linking with ld or gcc?
  2006-11-05 16:25 ` Harald van Dijk
@ 2006-12-08 17:41   ` Andreas Vinsander
  2006-12-09  7:34     ` Harald van Dijk
  0 siblings, 1 reply; 4+ messages in thread
From: Andreas Vinsander @ 2006-12-08 17:41 UTC (permalink / raw
  To: gentoo-dev

Harald van Dijk wrote:
> On Sun, Nov 05, 2006 at 06:47:07PM +0300, Peter Volkov (pva) wrote:
>> Hello.
>>
>> Short question: What shall we use to link libraries/programs: gcc or ld?
>> Why?
>>
>> A bit longer story: I have a problem during linking of wepattack on
>> amd64 systems. Linking stage issues warning:
>>
>> $ x86_64-pc-linux-gnu-ld  -o wepattack wepattack.o rc4.o wepfilter.o
>> log.o modes.o misc.o verify.o keygen.o -lpcap -lz -lcrypto
>> ld: warning: cannot find entry symbol _start; defaulting to
>> 0000000000400e10
>>
>> And resulted file is not executable. In google I found the most of
>> tutorials/howtos suggest to link with gcc but some programs still use
>> LD. From ld man page it's clear that it should link the program but this
>> is not working. So what is the right way to do that? Why?
> 
> Link using gcc unless your program is a very special case. _start is defined
> in /usr/lib/crt1.o (may be slightly different on amd64), and that as well as
> other object files typically required by every program will be pulled in by
> gcc.

Doing some reading up on the list... thus the late answer.

gnu make provides you with the variables/macros that is usable for
linking. Look for 'LINK.c' etc in the output of 'make -p -f/dev/null'.
It might be wise to use them instead of the actual linker since you
might wanna port your project to some other compiler etc in the future.

/Andreas
-- 
gentoo-dev@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [gentoo-dev] linking with ld or gcc?
  2006-12-08 17:41   ` Andreas Vinsander
@ 2006-12-09  7:34     ` Harald van Dijk
  0 siblings, 0 replies; 4+ messages in thread
From: Harald van Dijk @ 2006-12-09  7:34 UTC (permalink / raw
  To: gentoo-dev

On Fri, Dec 08, 2006 at 06:40:40PM +0100, Andreas Vinsander wrote:
> Harald van Dijk wrote:
> > On Sun, Nov 05, 2006 at 06:47:07PM +0300, Peter Volkov (pva) wrote:
> >> Hello.
> >>
> >> Short question: What shall we use to link libraries/programs: gcc or ld?
> >> Why?
> >>
> >> A bit longer story: I have a problem during linking of wepattack on
> >> amd64 systems. Linking stage issues warning:
> >>
> >> $ x86_64-pc-linux-gnu-ld  -o wepattack wepattack.o rc4.o wepfilter.o
> >> log.o modes.o misc.o verify.o keygen.o -lpcap -lz -lcrypto
> >> ld: warning: cannot find entry symbol _start; defaulting to
> >> 0000000000400e10
> >>
> >> And resulted file is not executable. In google I found the most of
> >> tutorials/howtos suggest to link with gcc but some programs still use
> >> LD. From ld man page it's clear that it should link the program but this
> >> is not working. So what is the right way to do that? Why?
> > 
> > Link using gcc unless your program is a very special case. _start is defined
> > in /usr/lib/crt1.o (may be slightly different on amd64), and that as well as
> > other object files typically required by every program will be pulled in by
> > gcc.
> 
> Doing some reading up on the list... thus the late answer.
> 
> gnu make provides you with the variables/macros that is usable for
> linking. Look for 'LINK.c' etc in the output of 'make -p -f/dev/null'.
> It might be wise to use them instead of the actual linker since you
> might wanna port your project to some other compiler etc in the future.

With any compiler in a Unix-like environment, and many compilers in
other environments, you can be sure it can be used to link. It's
extremely common existing practice which has even been standardised by
POSIX (`man 3p c99`, but the same was specified for the cc and c89
utilities). Assuming GNU make is used is far more likely to cause
problems when porting to some other platform.
-- 
gentoo-dev@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-12-09  7:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-05 15:47 [gentoo-dev] linking with ld or gcc? Peter Volkov (pva)
2006-11-05 16:25 ` Harald van Dijk
2006-12-08 17:41   ` Andreas Vinsander
2006-12-09  7:34     ` Harald van Dijk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox