11

I'm currently writing a little program in c++ on my 64bit Ubuntu Pc. By default eclipse compiles the program for a 64bit architecture. Since I want to use my little program on my server which is still 32bit, I need to be able to compile my program for 32bit. How could can I do that in eclipse? I've been fiddling for a while with the settings but nothing worked...

Cheers

2 Answers 2

21

I found the answer myself, after lots of searching and trying things out. This is a solution that works if you happen to have the same problem. For this to work the following packages have to be installed:

  • gcc/g++ with multilib

  • ia32-libs

Then right click on your project, and select "properties". Go to "C/C++ Build" and choose "settings". Under "GCC/G++ Compiler" add "-m32" to the command field (the field should now say "g++ -m32"). Do the same for "GCC/G++ Linker".

Now that you have added the flag, this should be compiled for 32bit. I'm using Eclipse Galileo, for the case that your interface looks different. I only added the "-m32" flag only under the "Release" profile, so my "Debug" builds are still 64bit.

1
  • 1
    apt-get install g++-multilib is the command to be used for installing g++ multilib library mentioned here. apt-get install libc6-dev-i386 is also needed sometimes depending on the additional libraries required for applications.
    – ViFI
    Dec 6, 2016 at 20:30
3

For those looking how to install the libraries mentioned by Basil on Linux (Ubuntu)

$ apt-get install lib32gcc1 libc6-i386 lib32z1 lib32stdc++6

$ apt-get install lib32asound2 lib32ncurses5 lib32gomp1 lib32z1-dev lib32bz2-dev

$ apt-get install g++-multilib

Source: http://sixarm.com/about/ubuntu-apt-get-install-ia32-for-32-bit-on-64-bit.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.