This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Fwd: Inconsistent warning/error message by GCC while linking 32/64 bit binary/library

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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]