gcc -m32 error /usr/bin/ld: skipping incompatible - gcc

I'm trying to compile an application for both 64bit and 32bit systems. During compilation I am receving an error for the 32bit application:
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.9/libstdc++.so when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.9/libstdc++.a when searching for -lstdc++
/usr/bin/ld: cannot find -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.9/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.9/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
collect2: error: ld returned 1 exit status
I've read around and found that I need gcc-multilib so I tried to install it:
me#ubuntu:~/bin/c/find-files$ sudo apt-get install gcc-multilib
Reading package lists... Done
Building dependency tree
Reading state information... Done
gcc-multilib is already the newest version (4:5.3.1-1ubuntu1).
The following packages were automatically installed and are no longer required:
linux-headers-4.8.0-41 linux-headers-4.8.0-41-generic
linux-image-4.8.0-36-generic linux-image-4.8.0-41-generic
linux-image-extra-4.8.0-36-generic linux-image-extra-4.8.0-41-generic
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
It's already installed. So I look a little more and found that I should be exporting to the lib32 directory:
me#ubuntu:~/bin/c/find-files$ export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib32:/usr/lib32:/usr/lib/i386-linux-gnu
Tried to compile again, same error. Then I though maybe if I used g++ and installed it's multilib:
me#ubuntu:~/bin/c/find-files$ sudo apt-get install g++-multilib
Reading package lists... Done
Building dependency tree
Reading state information... Done
g++-multilib is already the newest version (4:5.3.1-1ubuntu1).
The following packages were automatically installed and are no longer required:
linux-headers-4.8.0-41 linux-headers-4.8.0-41-generic
linux-image-4.8.0-36-generic linux-image-4.8.0-41-generic
linux-image-extra-4.8.0-36-generic linux-image-extra-4.8.0-41-generic
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.9/libstdc++.so when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.9/libstdc++.a when searching for -lstdc++
/usr/bin/ld: cannot find -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.9/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.9/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
collect2: error: ld returned 1 exit status
How can I cross compile an application for both 32bit and 64bit operating systems?

Related

cannot find -lstdc++ in ubuntu 14.04

I am using ubuntu 14.04 64 bit OS
when i am running my verilog code in synopsys vcs it shows me the following error, i think there might some missing packages in ubuntu, i search through but i didn't get nothing related to this
/usr/bin/ld: cannot find -lstdc++ so i have decided to post ths issue in this portal. Kindly help to rectify the issues
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.8/libstdc++.so when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.8/libstdc++.a when searching for -lstdc++
/usr/bin/ld: cannot find -lstdc++

/usr/bin/ld: cannot find -lgcc: No such file or directory

Recently, I was trying to compile a C program into 16-bit with this command:
gcc -m16 main.c
all was going well until I saw these errors:
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/11/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc: No such file or directory
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/libgcc_s.so.1 when searching for libgcc_s.so.1
/usr/bin/ld: skipping incompatible /lib/x86_64-linux-gnu/libgcc_s.so.1 when searching for libgcc_s.so.1
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libgcc_s.so.1 when searching for libgcc_s.so.1
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/11/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc: No such file or directory
collect2: error: ld returned 1 exit status
What is wrong and how do I fix these errors?

Valac incompatible libX11

For a vala file 'a.vala' using gtk:
$ valac a.vala --pkg gtk+-3.0
/usr/bin/ld: skipping incompatible /usr/lib/libX11.so when searching for -lX11
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/7/../../../libX11.so when searching for -lX11
/usr/bin/ld: skipping incompatible //lib/libX11.so when searching for -lX11
/usr/bin/ld: skipping incompatible //usr/lib/libX11.so when searching for -lX11
/usr/bin/ld: cannot find -lX11
/usr/bin/ld: skipping incompatible /usr/lib/libpthread.so when searching for -lpthread
collect2: error: ld returned 1 exit status
error: cc exited with status 256
Compilation failed: 1 error(s), 0 warning(s)
However, the following works..
$ valac a.vala --pkg gtk+-3.0 -C
$ gcc a.c `pkg-config gtk+-3.0 --cflags --libs`
Tried removing/installing glibc-devel.x86_64 and/or glibc-devel.i686 with no use.
I'm not sure if this can help but it worth mentioning that I used to use vala normally on Fedora 26 and this problem appeared after installing a fresh Fedora 27.

Error in caffe installation

I am facing a issue when i run the following command while installing caffe on fedora 21
make all
Output:
AR -o .build_release/lib/libcaffe.a
LD -o .build_release/lib/libcaffe.so
/usr/bin/ld: skipping incompatible /usr/lib/libleveldb.so when searching for -lleveldb
/usr/bin/ld: skipping incompatible /usr/lib/libleveldb.so when searching for -lleveldb
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.9.2/../../../libleveldb.so when searching for -lleveldb
/usr/bin/ld: skipping incompatible /lib/libleveldb.so when searching for -lleveldb
/usr/bin/ld: skipping incompatible /usr/lib/libleveldb.so when searching for -lleveldb
/usr/bin/ld: cannot find -lleveldb
/usr/bin/ld: cannot find -lsnappy
/usr/bin/ld: cannot find -lcblas
/usr/bin/ld: cannot find -latlas
collect2: error: ld returned 1 exit status
Makefile:544: recipe for target '.build_release/lib/libcaffe.so' failed
make: *** [.build_release/lib/libcaffe.so] Error 1
[root#parags-pc caffe]#
Some help please!
I still can't get rid of the last two (-lcblas and -latlas) errors. I have installed atlas and OpenBLAS long ago. Also I tried the following commands but with no success
echo "/usr/lib64/atlas" >/etc/ld.so.conf.d/atlas-x86_64.conf
ldconfig -v
Need some inputs!!
The leveldb present in your system seems to be of a different architecture, most probably a 32bit compiled leveldb and 64bit compiled caffe, or vice-versa.
The rest of the libraries are to be installed in Fedora before compiling Caffe.

Cannot find crtn.o, linking 32 bit code on 64 bit system

I'm attempting to assemble some 32-bit code using NASM and GCC on a 64-bit system. I use the following two commands
nasm -f elf32 -g -F stabs coc.asm
gcc -m32 -o coc coc.o
NASM appears to do fine, but LD complains:
/usr/bin/ld: cannot find crt1.o: No such file or directory
/usr/bin/ld: cannot find crti.o: No such file or directory
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6.1/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6.1/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: cannot find -lc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6.1/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6.1/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: cannot find crtn.o: No such file or directory
collect2: ld returned 1 exit status
I'm running Ubuntu 11.10, and I checked and I'm pretty sure libc is installed.
You are not assembling, but linking an executable, which needs OS startup files.
It seems you don't have gcc-*-multilib installed, which contains the necessary files: http://packages.ubuntu.com/oneiric/amd64/gcc-4.6-multilib/filelist
You need to install gcc-multilib to get the proper 32-Bit lib
I had a very similar problem on ubuntu 11.10. See my question on SO about this. What helped for me, was linking the crt*.o to /lib/. After that I never had other problems with this issue. A bit more of a cludge, but for me it solved the problems.

Resources