I build 32-bit application on 64-bit Linux (RH6).
I check how linker searches libraries during linkage and see that it gets found a right 32-bit library libz
but drops it, goes to seach further and gets found 64-bit version of it:
3885956: trying file=/lib/libz.so.1
3885956: search cache=/etc/ld.so.cache
3885956: trying file=/lib64/libz.so.1
After all linker says:
/usr/bin/ld: skipping incompatible /usr/lib64/libz.so when searching for -lz
/usr/bin/ld: cannot find -lz
collect2: ld returned 1 exit status
Could somebody explain me why linker does this and how to force it to get 32-bit library?
Thsnks.
PS. I use -m32 option but it does not help in this case.
UPDATE! It seems the investigation is transferred to another field - Electric Make. If I run emake (origina targeting case) it fails. If I copy-paste-execute command which emake is failed on then build is finished successfully.
So difference in contexts is suspected.
Have no idea how to investigate
UPDATE2
It is strange enough. Electric Make just drops common libraies like /usr/lib from search path (LD_LIBRARY_PATH) which it is called with and uses only paths which are in Clearcase file system. If it does not find necessary library there it gets ld's cache and searches there. Being met 64-bit libz.so (geos first in cache file) it stops searching and returns with error.