简体   繁体   English

在64位Linux上编译32位应用程序

[英]Compiling 32 Bit Application on 64 Bit Linux

I'm trying to compile a program for 32 bit on a 64 bit Kali Linux operating system. 我正在尝试在64位Kali Linux操作系统上为32位编译程序。

Here is my system information: 这是我的系统信息:

root@kali:~/Desktop# cat /proc/version
Linux version 3.18.0-kali3-amd64 (debian-kernel@lists.debian.org) (gcc version 4.7.2 (Debian 4.7.2-5) ) #1 SMP Debian 3.18.6-1~kali2 (2015-03-02)

When I try to compile my C project, it cannot find -lgcc : 当我尝试编译C项目时,找不到-lgcc

root@kali:~/Desktop/Project# make
cc -o libor libor.c -fno-stack-protector -z execstack -m32 -lpthread
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.7/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.7/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
collect2: error: ld returned 1 exit status
make: *** [all] Error 1

Note that I'm using the -m32 flag to force compilation for 32 bit. 请注意,我正在使用-m32标志来强制编译32位。

Like suggested elsewhere, the 32 bit libraries should be installed which I did using the following command: 像其他地方建议的那样,应该安装32位库,我使用以下命令进行了安装:

sudo apt-get install libc6-dev-i386

This however only changed the error message to the one seen above. 但是,这只会将错误消息更改为上面看到的错误消息。 I lost the previous one however I guess it no longer matters. 我丢失了前一个,但是我想它不再重要了。

Please note that existing answers didn't help me so this is not a duplicate. 请注意,现有的答案对我没有帮助,因此这不是重复的。

Try ensuring that your new 32-bit libraries are in the library search path. 尝试确保新的32位库位于库搜索路径中。 You can verify this by using the ldconfig command, and if the libraries' directories aren't listed, then use the tips in this web page: http://www.cyberciti.biz/faq/linux-setting-changing-library-path/ 您可以使用ldconfig命令进行验证,如果未列出库的目录,请使用此网页中的提示: http : //www.cyberciti.biz/faq/linux-setting-changing-library-路径/

I don't know that the above is the cause of your problem, but it may be worth a try? 我不知道以上是造成您问题的原因,但值得一试吗?

apt-get install gcc-multilib

应该可以。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM