我正在尝试为64bit
和32bit
系统编译应用程序。在编译期间,我收到了32bit
应用程序的错误:
/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
我已经阅读并发现我需要gcc-multilib
所以我尝试安装它:
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.
它已经安装好了。所以我再看一点,发现我应该导出到lib32
目录:
me@ubuntu:~/bin/c/find-files$ export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib32:/usr/lib32:/usr/lib/i386-linux-gnu
试图再次编译,同样的错误。然后我可能会使用g++
并安装它的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
如何为32bit
和64bit
操作系统交叉编译应用程序?