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.
-- 
[email protected] mailing list

Reply via email to