(Notice) This is a memo when I prepared an environment where I could also develop a windows application when I was developing a GUI program using wxWidget on ubuntu. This article was written on Google Sites a long time ago, and although the content is obsolete, I can't stand it disappearing, so I reprinted it. It has not been re-verified at the time of reprint (2020/8).
First, install a compiler (cross-compiler) that creates programs for windows on linux.
Packages to install
python
$ sudo apt-get install mingw-w64 binutils-mingw-w64 gcc-mingw-w64 g++-mingw-w64
Executable files (programs) created with gcc-mingw (generally) do not work on their own. You need two files, the compiled executable file and the mingw runtime library. Normal Windows users do not have the mingw runtime library, so you need to distribute the compiled program and the mingw library together.
The mingw library is included in the mingw32-runtime-package, so copy it to your current directory so you can distribute it with it.
runtime
$ cp /usr/share/doc/mingw32-runtime/mingwm10.dll.gz .
$ gunzip mingw10.dll
To run a program for windows on linux, you need a program to act for windows
install_wine
$ sudo apt-get install wine
hello.cpp
#include <iostream>
int main(int ac,char*av[]){
std::cout<<"hello"<<std::endl;
return 0;
}
test
$ i686-w64-mingw32-g++ -static-libgcc -static-libstdc++ hello.cpp
setenv4cross.sh
export CC=i686-w64-mingw32-gcc
export CXX=i686-w64-mingw32-c++
export LD=i686-w64-mingw32-ld
export AR=i686-w64-mingw32-ar
export AS=i686-w64-mingw32-as
export NM=i686-w64-mingw32-nm
export STRIP=i686-w64-mingw32-strip
export RANLIB=i686-w64-mingw32-ranlib
export DLLTOOL=i686-w64-mingw32-dlltool
export OBJDUMP=i686-w64-mingw32-objdump
export RESCOMP=i686-w64-mingw32-windres
export WINDRES=i686-w64-mingw32-windres
set
$ source setenv4cross.sh
pthread (You may not need to install pthread separately now)
http://sourceforge.net/projects/mingw/files/MinGW/Base/pthreads-w32/pthreads-w32-2.9.1/
From
install_pthread
$ export SANDBOX=~/src/cross
$ mkdir pthread
$ tar xvf pthreads-w32-2.9.0-mingw32-pre-20110507-2-src.tar.lzma --lzma
# $ pkgbuild -e prep
# $ pkgbuild -e patch
# $ pkgbuild -e configure
$ cd pthreads
$ make CROSS=i686-w64-mingw32- clean GC-inlined -f GNUmakefile
$ mkdir -p $SANDBOX/{include,lib,bin}
$ cp libpthreadGC2.a $SANDBOX/lib/
$ cp *.h $SANDBOX/include/
$ cp pthreadGC2.dll $SANDBOX/bin/
Compile and install Disable-shared etc. is up to you.
install wxWidgets
$ tar xjf wxWidgets-2.8.12.tar.bz
$ cd wxWidget-2.8.12
$ ./configure --prefix=/usr/local/i586-mingw32 --host=i586-mingw32msvc --enable-unicode --build=`./config.guess` --disable-shared
$ make
$ sudo make install
Test sample Don't forget to make a link to the runtime library.
$ cd samples
$ cd (What you want to try)
$ make
$ ln -s $SANDBOX/mingw10.dll .
(Execution)
$ make clean
Basically, you can use wx-config installed for cross compile.
MINGW_PREFIX=i586-mingw32msvc
CXX=$(MINGW_PREFIX)-g++
LD=$(MINGW_PREFIX)-ld
WXCONFIG=/usr/local/i586-mingw32/bin/wx-config
WXCPPFLAGS=`$(WXCONFIG) --cppflags`
WXLIBS=`$(WXCONFIG) --libs`
t.exe: t.cpp
$(CXX) $(WXCPPFLAGS) $(CPPFLAGS) -o t.exe t.cpp $(WXLIBS)
Search keywords: ubuntu, mingw, wine, cross complier, setup