I have a c++ codebase that I need to build both windows and unix versions of. It is important that the windows executable work without cygwin or similar installed. Oh, and I'm trying to achieve this from ubuntu.
I've been trying to figure out how to make boost-build take care of it, but have so far come up short.. For simplicity assume this project structure:
| |- core/
| | |- number.cpp
| | |- number.hpp
| |- main.cpp
In an attempt to make boost-build produce windows binaries as a first step, I create a user-config.jam file in my home directory containing the following:
using gcc : 4.4 : i586-mingw32msvc-g++ : <rc>i586-mingw32msvc-windres <archiver>i586-mingw32msvc-ar ;
My jamroot file looks like this:
exe hello :
[ glob-tree *.cpp ]
: : <target-os>windows
But when I run
bjam I get a unix executable (no extension) but not a windows executable. Renaming the application with a .exe extension and running on windows does not work. I tried various options for bjam, like
bjam --toolset=gcc --target-os=windows,
bjam --toolset=gcc-mingw --target-os=windows etc. but noting seems to work..
For the record, mingw is properly installed and working.. Calling the compiler manually produces correct output files.
Also, how do I get bjam to build a version for each toolset listed in my user-config.jam file?
Bonus question: Eventually, I need to link against one boost library and one custom prebuilt library. How would I go about specifying different libraries for the different target systems?
UPDATE I downloaded the script from http://mingw-cross-env.nongnu.org/ which allowed me to compile a mingw as well as boost libraries in one go, so that problem is taken care of.. I found a way to make bjam call the mingw compiler (I am at a different computer so I cannot provide the solution at this time).. The other questions are still not resolved.
Unfortunately I don't think this can be done (I've failed many times) and I think the reason is because mingw is not suppported for compiling Boost. The only way people seem to have accomplished this is to maintain a separate build environment under win32 using MS Visual Studio.
From your question it's unclear if you're using bjam to build your application, or if you're just trying to build Windows versions of the Boost libraries (.lib or .dll files) to link with your application later. In my attempts I have tried to do this the 'usual' way, in that Windows versions of the Boost libraries are compiled, then the app is compiled separately with mingw32 and linked with Boost.
Unfortunately my stumbling block so far is that I can only get two outcomes - either the build fails when compiling Boost into Win32 dynamic libraries (.dll), or win32 static libraries are successfully built, but then libtool refuses to link them in with the app.
Have a look at the PKGBUILD file that Arch Linux uses to compile mingw32-boost as you might get some hints from how they do it. It seems that
bjam threadapi=win32 target-os=windows is enough. Don't forget to set your prefix correctly though, so you don't overwrite your native libraries with win32 versions!