MinGW

From Schmid.wiki
Jump to: navigation, search

Cross development using Gentoo should be done with the crossdev tool. An alternative is running your Windows compiler using the Windows emulator Wine.

Running MinGW on Linux using Wine

How to run MinGW g++ with Wine:

  • Install Wine
  • Create a directory to be used as the root of your fake Windows box, e.g.:
mkdir win32
cd win32
binutils-2.17.50-20060824-1.tar.gz
gcc-core-3.4.5-20060117-1.tar.gz
gcc-g++-3.4.5-20060117-1.tar.gz
mingw-runtime-3.13-20070825-1.tar.gz
w32api-3.10.tar.gz
  • Unpack into a new MinGW directory and clean up tarballs, e.g.:
mkdir mingw
tar -Cmingw -xvzf binutils-2.17.50-20060824-1.tar.gz
...
rm *.tar.gz
  • Create a source file test.cpp:
test.cpp
  • Start CMD using Wine:
wine cmd
  • Set path in CMD, e.g.:
path z:\home\username\win32\mingw\bin
  • And compile test.cpp:
g++ test.cpp

wxWidgets

As I cannot figure out how to build wxWidgets without MSYS, and MSYS is a real pain under Wine (even though it does work), I recommend bootstrapping wxWidgets using MSYS on a Windows box:

./configure
make

The entire wxWidgets directory can then be copied to the Linux machine. The wx-config command will not work properly, but you can run it and adapt the options to your setup. When not installed, you can find wx-config in a subdir, e.g. lib/wx/config/msw-ansi-release-2.8. The output of

./msw-ansi-release-2.8 --cxxflags --libs

would be something like

-I/usr/local/lib/wx/include/msw-ansi-release-2.8 -I/usr/local/include/wx-2.8
  -DWXUSINGDLL -D__WXMSW__ -mthreads
-L/usr/local/lib  -mthreads  -Wl,--subsystem,windows -mwindows
  -lwx_msw_aui-2.8 -lwx_msw_xrc-2.8 -lwx_msw_qa-2.8 -lwx_msw_html-2.8
  -lwx_msw_adv-2.8 -lwx_msw_core-2.8 -lwx_base_xml-2.8 -lwx_base_net-2.8
  -lwx_base-2.8

You could create a BATCH file for compiling, e.g.:

@echo off

set root=z:/home/username/win32
path %root%/mingw/bin

set    wxlib=%root%/wxWidgets-2.8.4/lib
set    wxinc=%root%/wxWidgets-2.8.4/include
set wxconfig=%wxlib%/wx/include/msw-ansi-release-2.8

echo PATH: %path%
echo WxWidgets includes: %wxinc%
echo WxWidgets includes: %wxconfig%
echo WxWidgets libraries: %wxlib%

echo on

g++ -c -I%wxconfig% -I%wxinc% -DWXUSINGDLL -D__WXMSW__ -mthreads minimal.cpp
g++ minimal.o -L%wxlib%  -mthreads  -Wl,--subsystem,windows -mwindows
    -lwx_msw_aui-2.8 -lwx_msw_xrc-2.8 -lwx_msw_qa-2.8 -lwx_msw_html-2.8
    -lwx_msw_adv-2.8 -lwx_msw_core-2.8 -lwx_base_xml-2.8 -lwx_base_net-2.8
    -lwx_base-2.8 -o minimal.exe
Personal tools