Author Topic: How-to: cross-compile 32 bit app under 64-bit Linux  (Read 8366 times)

Offline kencamargo

  • Multiple posting newcomer
  • *
  • Posts: 110
How-to: cross-compile 32 bit app under 64-bit Linux
« on: January 30, 2010, 04:40:23 am »
Just tested with Ubuntu Karmic:

(1) Install the multilib support for g++ and gcc (synaptic or sudo apt-get install):
g++-multilib
gcc-multilib

(2) Get the .deb 32 bit packages - donwload, not through synaptic:
libwxbase2.8-0_2.8.10.1-1_i386.deb
libwxbase2.8-dbg_2.8.10.1-1_i386.deb
libwxbase2.8-dev_2.8.10.1-1_i386.deb
libwxgtk2.8-0_2.8.10.1-1_i386.deb
libwxgtk2.8-dev_2.8.10.1-1_i386.deb
wx2.8-headers_2.8.10.1-1_i386.deb
wx2.8-i18n_2.8.10.1-1_all.deb
wx-common_2.8.10.1-1_i386.deb
This is important, if you use synaptic or apt-get to get the binaries, you'll only see the 64-bit versions

(3) Unpack each of them, and then for each unpack the data.tar.gz file.
They can't be installed with gdebi or other package manager, because they will (correctly) show as a wrong architecture, and even if it did, things would probably go to the wrong places.

(4) Move the directories:
move the directory ./lib to /usr/lib32
move the directory ./include to /usr/i32 (or some other name that is not include)
discard the rest

(5) Set build options:
compiler/other options
-m32 -I/usr/lib32/wx/include/gtk2-unicode-release-2.8 -I/usr/i32/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -pthread

Note the -I/usr/i32; if a different name is chosen, it should be used there.
I believe the same effect could be achieved setting up something or other in the wx-config script, but I don't know how. Suggestions are welcome.

linker/other options
-m32 `wx-config --libs`

Et voilĂ . The interesting thing is that when the multilib support is installed, the 32 bit apps will also run under the 64 bit distro.

Note: I haven't tested debugging yet.

Enjoy,
Ken

Offline kencamargo

  • Multiple posting newcomer
  • *
  • Posts: 110
Re: How-to: cross-compile 32 bit app under 64-bit Linux
« Reply #1 on: January 30, 2010, 07:30:53 pm »
Nothing like a good night of sleep...

Going back to item (4) in the previous list:

(4b) Create an i32 directory under /usr, and create the following structure under it:
/lib
   /wx
      /include

(4c) Copy the "include" directory to /usr/i32, so now you'll have this:
/usr
   /i32
      /include <--- that's where the 32 bit include files go
      /lib
         /wx
            /include

(4d) cd to /usr/i32/lib/wx/include

(4e) Make a symlink there to /usr/lib32/wx/include/gtk2-unicode-release-2.8
Now the complete tree should look like this
/usr
   /i32
      /include
         /wx2.8
      /lib
         /wx
            /include
               /gtk2-unicode-release-2.8 (the symlink you just created)

This will simplify the configuration; instead of the previous, do this:

(5b) Put this into /compiler/other options in code::blocks:
-m32 `wx-config --prefix=/usr/i32 --cflags`

Still didn't test debugging.

If anyone wishes to add these instructions to the cross-compiling how-to in the wiki, I have the instructions in one text file.

Hoping someone else finds this useful,

Ken

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: How-to: cross-compile 32 bit app under 64-bit Linux
« Reply #2 on: January 30, 2010, 08:26:22 pm »
If anyone wishes to add these instructions to the cross-compiling how-to in the wiki, I have the instructions in one text file.
Why don't you do it yourself? The WiKi's content can be edited by any user (that's the idea of a WiKi... ;-)). You only need to login using your name/pw from the forum and start typing. Just make sure you select the right section. A little "nice" formatting is helpful, too.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline kencamargo

  • Multiple posting newcomer
  • *
  • Posts: 110
Re: How-to: cross-compile 32 bit app under 64-bit Linux
« Reply #3 on: January 30, 2010, 11:54:56 pm »
Why don't you do it yourself? The WiKi's content can be edited by any user (that's the idea of a WiKi... ;-)). You only need to login using your name/pw from the forum and start typing. Just make sure you select the right section. A little "nice" formatting is helpful, too.

I wasn't sure if I could do that, but I was also afraid I could screw something up. Gonna try. :)

Ken

Offline kencamargo

  • Multiple posting newcomer
  • *
  • Posts: 110
Re: How-to: cross-compile 32 bit app under 64-bit Linux
« Reply #4 on: January 31, 2010, 12:42:32 am »
Why don't you do it yourself?

Just did. It's under "User Documentation" and then "4. COmpilers", I created a new page called "Developing 32 bit apps under 64 bit Linux (Ubuntu)".

Nice enough? :)