This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Fwd: Inconsistent warning/error message by GCC while linking 32/64 bit binary/library
- From: Nick Clifton <nickc at redhat dot com>
- To: vijay nag <vijunag at gmail dot com>, binutils at sourceware dot org
- Date: Tue, 15 Dec 2015 12:12:45 +0000
- Subject: Re: Fwd: Inconsistent warning/error message by GCC while linking 32/64 bit binary/library
- Authentication-results: sourceware.org; auth=none
- References: <CAKhyrx8stbzri72uXkfjFjWyD6htfbCzfVaLH_RTMRZ6DGGxvQ at mail dot gmail dot com> <CAKhyrx_wNSaGqNGMDaULvA-9KA9ibp0EjV7LaoK7a6B38f-Qow at mail dot gmail dot com>
Hi Vijay,
Vijay bsd84:~/lib]# gcc -g -m32 b.o -L. -la
/usr/bin/ld: skipping incompatible ./liba.a when searching for -la
/usr/bin/ld: cannot find -la
Vijay bsd84:~/lib]# gcc -g -m32 b.o liba.a
/usr/bin/ld: warning: i386:x86-64 architecture of input file
`liba.a(a.o)' is incompatible with i386 output
The warnings are different because you are asking the linker to perform
slightly different things. In the first example the "-la" option means
"search all of the library paths for a library called 'a' and include it
at this point in the link". Hence the linker issues a warning message
when it finds a library called 'a', but it is of an incompatible
architecture. The assumption being that there is likely to be a problem
with one or more of the -L options provided since they have lead the
linker to look in a directory containing incompatible binaries.
In the second example you have provided the location of the 'a' library
directly - no searching is needed by the linker. In this case a
different warning is issued because the problem is different - you are
asking the linker to link in an incompatible binary, rather than asking
it to search in the wrong place.
I hope that this helps.
Cheers
Nick