Pergunta

I would like to cross compile a wxWidgets application for windows from Linux using the codeblocks IDE.

I have read through these instructions which provide some useful information, but the instructions do not cover codeblocks.

Foi útil?

Solução

These are the steps I followed on Ubuntu 13.10 (Saucy Salamander)

Update the system and install mingw32 and wine:

sudo apt-get update && sudo apt-get upgrade
sudo apt-get install mingw32 wine

Install wxWidgets 2.8 from source:

sudo su -
cd /opt
wget http://downloads.sourceforge.net/project/wxwindows/2.8.12/wxWidgets-2.8.12.tar.gz
tar -xvzf wxWidgets-2.8.12.tar.gz
cd wxWidgets-2.8.12/
./configure --prefix=/usr/local/i586-mingw32 --host=i586-mingw32msvc --build=i686-linux --disable-shared --enable-unicode
make
make install

Install codeblocks

sudo apt-get install codeblocks codeblocks-contrib

Open codeblocks, then setup as follows:

Settings > Compiler > 

   Selected Compiler > GNU GCC Compiler > Copy > New Compiler Name : MinGW Compiler

   Selected Compiler > MinGW Compiler

   Search Directories > Compiler > Add : /usr/i586-mingw32msvc/include/
   Search Directories > Linker > Add : /usr/i586-mingw32msvc/lib/
   Search Directories > Resource Compiler > Add : /usr/i586-mingw32msvc/include/

   Toolchain Executables >
       Program Files >
           Compilers Installation Directory : /usr/i586-mingw32msvc/
           C Compiler : i586-mingw32msvc-gcc
           C++ Compiler : i586-mingw32msvc-g++
           Dynamic Linker : i586-mingw32msvc-g++
           Static Linker : i586-mingw32msvc-ld
      Additional Paths : /usr/bin

Compiler Settings >  Other Options : `/usr/local/i586-mingw32/bin/wx-config --cxxflags` 
Linker Settings > Other Options : `/usr/local/i586-mingw32/bin/wx-config --libs` 

Now create a new project in codeblocks, the key fields are as follows:

New Project > wXWidgets Project
    wXWidgets > 2.8.x
    Preferred GUI Builder > wxSmith
    Compiler > MinGW Compiler

In Codeblocks, click on compile - this sets up the applications output folder which we need in the next step.

In a terminal window, copy required mingwm10.dll to output folder:

cd <your applications Debug folder>
cp /usr/share/doc/mingw32-runtime/mingwm10.dll.gz .
gunzip mingwm10.dll.gz

Now run with wine:

wine ./youappname

To run your application on windows machine, copy mingwm10.dll and your appname executable to a windows machine. Rename your appname to have the suffix .exe. Double click to run.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top