Difference between revisions of "Cross Compiling wxWidgets Applications on Linux"
Line 23: | Line 23: | ||
It is part of many linux distributions. | It is part of many linux distributions. | ||
− | On debian the basepackage is called ''mingw32'' and can be installed by typing | + | On debian the basepackage is called ''mingw32'' and can be installed by typing |
+ | sudo apt-get install mingw32 | ||
+ | at the command-line.<br /> | ||
It's up to you to find out the name of the package and install it using your preferred package-manager or either compile it by hand. | It's up to you to find out the name of the package and install it using your preferred package-manager or either compile it by hand. | ||
==wxWidgets cross-build== | ==wxWidgets cross-build== | ||
Line 32: | Line 34: | ||
You can download the source-code either from my [http://apt.jenslody.de/pool/ server's software pool] or from the [http://www.wxwidgets.org/ wxWidgets] download page. | You can download the source-code either from my [http://apt.jenslody.de/pool/ server's software pool] or from the [http://www.wxwidgets.org/ wxWidgets] download page. | ||
− | Unpack the sources and type configure it with | + | Unpack the sources and type configure it with |
+ | ./configure prefix=/usr/i586-mingw32msvc --host=i586-mingw32msvc --enable-unicode --disable-shared | ||
The prefix depends on your MinGW32 installation, either does the host. The other switches can be changed as you prefer it, with oine exception (at the moment):<br /> | The prefix depends on your MinGW32 installation, either does the host. The other switches can be changed as you prefer it, with oine exception (at the moment):<br /> | ||
I wasn't able to build any application with the shred version of wxWidgets and to run it on MS WIndows. It only works with statically linked dll's. | I wasn't able to build any application with the shred version of wxWidgets and to run it on MS WIndows. It only works with statically linked dll's. | ||
− | You can see the available switches with | + | You can see the available switches with |
+ | ./configure --help | ||
+ | |||
If everything wents right you get a message like this: | If everything wents right you get a message like this: | ||
− | |||
− | |||
+ | Configured wxWidgets 2.8.7 for `i586-pc-mingw32msvc' | ||
+ | |||
Which GUI toolkit should wxWidgets use? msw | Which GUI toolkit should wxWidgets use? msw | ||
Should wxWidgets be compiled into single library? yes | Should wxWidgets be compiled into single library? yes | ||
Line 60: | Line 65: | ||
libmspack no | libmspack no | ||
sdl no | sdl no | ||
− | |||
Now you can build the libraries with | Now you can build the libraries with | ||
− | + | make | |
− | make | + | make install |
− | make install | ||
− | |||
If you use my binaries you should be able to call <code>wx-config</code> directly.<br /> | If you use my binaries you should be able to call <code>wx-config</code> directly.<br /> | ||
As test you can run <pre>wx-config --list</pre>. | As test you can run <pre>wx-config --list</pre>. | ||
The ouput should look like | The ouput should look like | ||
− | |||
Default config is gtk2-unicode-release-2.8 | Default config is gtk2-unicode-release-2.8 | ||
− | + | ||
Default config will be used for output | Default config will be used for output | ||
− | + | ||
Alternate matches: | Alternate matches: | ||
base-unicode-release-2.8 | base-unicode-release-2.8 | ||
− | + | ||
Also available in /usr: | Also available in /usr: | ||
i586-mingw32msvc-msw-unicode-debug-2.8 | i586-mingw32msvc-msw-unicode-debug-2.8 | ||
i586-mingw32msvc-msw-unicode-release-2.8 | i586-mingw32msvc-msw-unicode-release-2.8 | ||
i586-mingw32msvc-msw-unicode-release-static-2.8 | i586-mingw32msvc-msw-unicode-release-static-2.8 | ||
− | + | ||
You can see the cross-compile configurations starting with ''i586-mingw32msvc-msw''. | You can see the cross-compile configurations starting with ''i586-mingw32msvc-msw''. | ||
If you don't see any cross-compile configurations you have to use the appropriate wx-config directly: | If you don't see any cross-compile configurations you have to use the appropriate wx-config directly: | ||
− | + | /usr/i586-mingw32msvc/lib/wx/config/i586-mingw32msvc-msw-unicode-release-static-2.8 --list | |
− | /usr/i586-mingw32msvc/lib/wx/config/i586-mingw32msvc-msw-unicode-release-static-2.8 --list | ||
− | |||
(The instruction may differ according to your configuration.)<br /> | (The instruction may differ according to your configuration.)<br /> | ||
If the output shows your cross-build targets, everything is okay. If not something went wrong with compiling your wxWidgets cross-libraries. | If the output shows your cross-build targets, everything is okay. If not something went wrong with compiling your wxWidgets cross-libraries. | ||
Line 97: | Line 96: | ||
If everything is installed you have to prepare Code::Blocks for cross-compiling. | If everything is installed you have to prepare Code::Blocks for cross-compiling. | ||
− | Therefore you need a special compiler based on ''GNU GCC compiler''. | + | Therefore you need a special compiler based on '''<code>''GNU GCC compiler''</code>'''. |
+ | |||
+ | Open '''<code>''Settings -> Compiler and Debugger ... -> Global compiler settings''</code>''', chose '''<code>''GNU GCC compiler''</code>''' and then click the |
Revision as of 20:08, 16 March 2008
This document is still under construction by Jens, but I'm working on it. Please be patient.
For the moment you can also look [/index.php/topic,7978.0.html here]
18:54, 16 March 2008 (CET)
This document describes how to setup Code::Blocks to compile applications that use the wxWidgets toolkit for MS Windows from within Linux.
I tested it on debian sid, but it should also work on other distributions.
Needed software
Code::Blocks
You can download prebuild binaries Code::Blocks from the download page.
If you prefer to compile Code::Blocks yourself, you have the choice between downloading the sourcecode of the actual release as tarball from the official download page or to download the newest version via svn.
A guide to build Code::Blocks from svn can be found in the Nightly Cookbook.
The newest svn-versions are also available as prebuild binaries made available by users.
You can find links to the downloadpages in the actual posts in the [/index.php/board,20.0.html Nightly Builds] forum.
MinGW32
MingW32 is the cross-build version of the Minimalistic Gnu for Windows compiler suite (a port of the Gnu Compiler Suite for the MS Windows platform).
It is part of many linux distributions.
On debian the basepackage is called mingw32 and can be installed by typing
sudo apt-get install mingw32
at the command-line.
It's up to you to find out the name of the package and install it using your preferred package-manager or either compile it by hand.
wxWidgets cross-build
For debian-users I have made prebuild binary packages available on my server. I guess they are also usable on Ubuntu, but you have to try it yourself.
I don't know if there are downloadable packages available in/for other distros, but you can build it on your own.
You can download the source-code either from my server's software pool or from the wxWidgets download page.
Unpack the sources and type configure it with
./configure prefix=/usr/i586-mingw32msvc --host=i586-mingw32msvc --enable-unicode --disable-shared
The prefix depends on your MinGW32 installation, either does the host. The other switches can be changed as you prefer it, with oine exception (at the moment):
I wasn't able to build any application with the shred version of wxWidgets and to run it on MS WIndows. It only works with statically linked dll's.
You can see the available switches with
./configure --help
If everything wents right you get a message like this:
Configured wxWidgets 2.8.7 for `i586-pc-mingw32msvc' Which GUI toolkit should wxWidgets use? msw Should wxWidgets be compiled into single library? yes Should wxWidgets be compiled in debug mode? no Should wxWidgets be linked as a shared library? no Should wxWidgets be compiled in Unicode mode? yes What level of wxWidgets compatibility should be enabled? wxWidgets 2.4 no wxWidgets 2.6 yes Which libraries should wxWidgets use? jpeg builtin png builtin regex builtin tiff builtin zlib builtin odbc no expat builtin libmspack no sdl no
Now you can build the libraries with
make make install
If you use my binaries you should be able to call wx-config
directly.
As test you can run
wx-config --list
.
The ouput should look like
Default config is gtk2-unicode-release-2.8 Default config will be used for output Alternate matches: base-unicode-release-2.8 Also available in /usr: i586-mingw32msvc-msw-unicode-debug-2.8 i586-mingw32msvc-msw-unicode-release-2.8 i586-mingw32msvc-msw-unicode-release-static-2.8
You can see the cross-compile configurations starting with i586-mingw32msvc-msw.
If you don't see any cross-compile configurations you have to use the appropriate wx-config directly:
/usr/i586-mingw32msvc/lib/wx/config/i586-mingw32msvc-msw-unicode-release-static-2.8 --list
(The instruction may differ according to your configuration.)
If the output shows your cross-build targets, everything is okay. If not something went wrong with compiling your wxWidgets cross-libraries.
In the further part of this document I'll use the paths I used in the example configure-line.
Preparing Code::Blocks
If everything is installed you have to prepare Code::Blocks for cross-compiling.
Therefore you need a special compiler based on GNU GCC compiler
.
Open Settings -> Compiler and Debugger ... -> Global compiler settings
, chose GNU GCC compiler
and then click the