Configure for cross-compiling (Linux & Windows)

Eclipse setup

 
 
 
 
 
 
 
 

If you use the Eclipse IDE, here is a description how to setup up a new C++ project for cross-compiling with the wxWidgets library (but it also works with other libraries). At least, Eclipse version 3.2 with the latest CDT plugin is required. The wxWidgets library has already to be prepared.

  1. Run Eclipse and create a new Managed Make C++ Project and use as project type Executable (Gnu)
  2. Start the project settings Project properties -> C/C++ Build -> Tool Settings (Debug)
  3. Open a console and run the following commands and write its results to the project properties: wx-config --debug --cxx into GCC C++Compiler -> Command

    wx-config --debug --cc into GCC C Compiler -> Command

    wx-config --debug --cxxflags write all paths from -I<path> into GCC C++Compiler -> Directories
    write all defines from -D<define> into GCC C++Compiler -> Preprocessor

    wx-config --debug --ld write all settings and the linker command into GCC Linker -> Command and GCC Linker -> Miscellaneous -> Linker flags

    wx-config --debug --libs put all libs from -l<lib> into GCC Linker -> Libraries
    put all paths from -L<path> into GCC Linker -> Libraries -> Search Path
    put all other settings into GCC Linker -> Miscellaneous -> Linker flags
    Warning: do no use the compiler switch -shared. It does not work here; the libraries are shared on linux by default.
  4. Do the same for the release build, but start the wx-config command with --debug=no
  5. Copy the debug build target: Project properties -> C/C++ Build -> Manage -> New
    Set the Name to Win32Debug and Copy from to Debug
  6. Copy the release build target: Project properties -> C/C++ Build -> Manage -> New
    Set the Name to Win32Release and Copy from to Release
  7. Open a console and enter: cd /usr/local/i586-mingw32msvc/bin
  8. Do the same project setting steps as above, for the Win32 debug and release build, but use the script in the current directory ./wx-config. Don't forget to start the command with ./, otherwise the shell will execute the wx-config command in the search path (usually /usr/bin)
  9. Set the extension to exe into Project properties -> C/C++ Build -> Build Settings -> Artifact extension
  10. Select also the binary parser for windows in Project properties -> C/C++ Build -> Binary Parser -> PE Windows Parser
  11. If you want to use the MinGW runtime DLL, copy it from /usr/share/doc/mingw32-runtime/mingwm10.dll into the folder of your executable.
    Otherwise, add the static libraries libminwg*.a to to GCC Linker -> Libraries (but use only <name> from the filename lib<name>.a)
  12. If you are using the DLL version of wxWidgets, copy the DLL(s) from /usr/local/i586-mingw32msvc into the folder of your executable
  13. You will probably need to link against some windows libraries, check the linker output for missing functions. Add the needed files from the folder /usr/i586-mingw32msvc/lib to GCC Linker -> Libraries (but use only <name> from the filename lib<name>.a)