1 |
On Fri, Dec 08, 2006 at 06:40:40PM +0100, Andreas Vinsander wrote: |
2 |
> Harald van Dijk wrote: |
3 |
> > On Sun, Nov 05, 2006 at 06:47:07PM +0300, Peter Volkov (pva) wrote: |
4 |
> >> Hello. |
5 |
> >> |
6 |
> >> Short question: What shall we use to link libraries/programs: gcc or ld? |
7 |
> >> Why? |
8 |
> >> |
9 |
> >> A bit longer story: I have a problem during linking of wepattack on |
10 |
> >> amd64 systems. Linking stage issues warning: |
11 |
> >> |
12 |
> >> $ x86_64-pc-linux-gnu-ld -o wepattack wepattack.o rc4.o wepfilter.o |
13 |
> >> log.o modes.o misc.o verify.o keygen.o -lpcap -lz -lcrypto |
14 |
> >> ld: warning: cannot find entry symbol _start; defaulting to |
15 |
> >> 0000000000400e10 |
16 |
> >> |
17 |
> >> And resulted file is not executable. In google I found the most of |
18 |
> >> tutorials/howtos suggest to link with gcc but some programs still use |
19 |
> >> LD. From ld man page it's clear that it should link the program but this |
20 |
> >> is not working. So what is the right way to do that? Why? |
21 |
> > |
22 |
> > Link using gcc unless your program is a very special case. _start is defined |
23 |
> > in /usr/lib/crt1.o (may be slightly different on amd64), and that as well as |
24 |
> > other object files typically required by every program will be pulled in by |
25 |
> > gcc. |
26 |
> |
27 |
> Doing some reading up on the list... thus the late answer. |
28 |
> |
29 |
> gnu make provides you with the variables/macros that is usable for |
30 |
> linking. Look for 'LINK.c' etc in the output of 'make -p -f/dev/null'. |
31 |
> It might be wise to use them instead of the actual linker since you |
32 |
> might wanna port your project to some other compiler etc in the future. |
33 |
|
34 |
With any compiler in a Unix-like environment, and many compilers in |
35 |
other environments, you can be sure it can be used to link. It's |
36 |
extremely common existing practice which has even been standardised by |
37 |
POSIX (`man 3p c99`, but the same was specified for the cc and c89 |
38 |
utilities). Assuming GNU make is used is far more likely to cause |
39 |
problems when porting to some other platform. |
40 |
-- |
41 |
gentoo-dev@g.o mailing list |