I'm trying to compile a 32-bit C application on Ubuntu Server 12.04 LTS 64-bit using gcc 4.8. I'm getting linker error messages about incompatible libraries and skipping -lgcc
. What do I need to do to get 32 bit apps compiled and linked?
相关问题
- Why doesn't php sleep work in the windows-subs
- Installing Pydev for Eclipse throws error
- Error building gcc 4.8.3 from source: libstdc++.so
- what's the role of libopenssl-ruby?
- Docker why isn't $USER environment variable se
相关文章
- 为什么nfs在不同版本的Linux下安装的文件都不一样
- Incompatible JavaHl library loaded
- Python - Node.js (V8) runtime is not available on
- Ubuntu graphviz 'sfdp' not working
- Gearman , php extension problem : Class 'Gearm
- Decrease the tabs bar height in gnome terminal
- “/usr/sbin/sendmail/” Not found
- Printing the response content body when using curl
Ubuntu 16.04
For some reason, on Ubuntu 17.04, I also needed to install the version specific one:
Then a minimal hello world:
compiles without warning under:
and:
gives:
Hello world!
as expected, and:says:
and:
also gives:
Hello world!
but would fail for anx86_64
executableFurthermore, I have:
So I think it works :-)
See also: Cannot find crtn.o, linking 32 bit code on 64 bit system
It is a shame that this package conflicts with the cross compilers like
gcc-arm-linux-gnueabihf
https://bugs.launchpad.net/ubuntu/+source/gcc-defaults/+bug/1300211Running versions of the question:
We are able to run 32-bit programs directly on 64-bit Ubuntu because the Ubuntu kernel is configured with:
according to:
whose help on the kernel source tree reads:
This is in turn possible because x86 64 bit CPUs have a mode to run 32-bit programs that the Linux kernel uses.
TODO: what options does
gcc-multilib
get compiled differently thangcc
?Multiarch installation is supported by adding the architecture information to the package names you want to install (instead of installing these packages using alternative names, which might or might not be available).
See this answer for more information on (modern) multiarch installations.
In your case you'd be better off installing the 32bit gcc and libc:
It will install the 32-bit libc development and gcc packages, and all depending packages (all 32bit versions), next to your 64-bit installation without breaking it.
To get Ubuntu Server 12.04 LTS 64-bit to compile gcc 4.8 32-bit programs, you'll need to do two things.
Make sure all the 32-bit gcc 4.8 development tools are completely installed:
sudo apt-get install lib32gcc-4.8-dev
Compile programs using the -m32 flag
gcc pgm.c -m32 -o pgm