Reputation: 727
I have downloaded "boost" (1.40.0) source code from their homepage "www.boost.org". I have Linux (Ubuntu 9.04 Jaunty) installed and trying to compile the boost libraries to the "WINDOWS" version (e.g. ".dll", NOT ".so") from my "LINUX" machine.
And now an important question:
IS IT POSSIBLE TO COMPILE TO THE "WINDOWS" BOOST LIBRARIES FROM "LINUX" (if someone say "yes" I will trust him only if he has already done it before of will write here a solution which will work for me. Sorry for that pessimism but I am trying to do this about for 3 days and nothing positive so far)?
So far I have compiled c++ programs this way. For compiling from Linux to Linux I have used "gcc" (or "g++") compiler. For compiling from Linux to Windows I have used "i586-mingw32msvc-gcc" (or "i568-mingw32msvc-g++") compiler (which is contained in "mingw32" package for "Ubuntu" for example).
So this strategy I have wanted to use also to compile boost libraries and I have tried this so far (after reading the "Getting started" article on the boost homepage):
--1. I have run "bootstrap.sh" from the "root" boost source code directory:
./bootstrap.sh
--2. Then I have changed one thing in the file "project-config.jam" (from "using gcc ;"):
using gcc : : i586-mingw32msvc-gcc ;
--3. And finally run "bjam" executable:
./bjam stage
But instead of creation of the "Windows" version of the boost libraries I got lots of error-messages.
Can anybody help me?
Thanks in advance.
Petike
Upvotes: 14
Views: 11259
Reputation: 41
There is a very simple procedure to follow to cross build boost from linux to windows here :
https://web.archive.org/web/20110604002004/http://www.vle-project.org/wiki/Cross_compilation_Win32
Upvotes: 3
Reputation: 2593
This is the commands I use. I have tested them for boost 1.46 and 1.49.
To begin, create links to the compiler inside /usr/i686-w64-mingw32/bin. You can run this script :
#!/bin/bash
binDir="/usr/bin"
destDir="/usr/i686-w64-mingw32/bin"
cd "$binDir"
mkdir -p "$destDir"
for name in $(ls i686-w64-mingw32*); do
newName=$(echo "$name" | sed 's/i686-w64-mingw32-//g')
if [ -f "$destDir/$newName" ]; then
rm "$destDir/$newName"
fi
ln -s "$binDir/$name" "$destDir/$newName"
done
Then, install bjam. On ubuntu / debian, it is included in the package "libboost1.48-dev"
apt-get install libboost1.48-dev
To finish, become root and run
env PATH=/usr/i686-w64-mingw32/bin:$PATH bjam toolset=gcc target-os=windows variant=release threading=multi threadapi=win32 link=static --prefix=/usr/i686-w64-mingw32 -j 4 --without-mpi --without-python -sNO_BZIP2=1 -sNO_ZLIB=1 --layout=tagged install
Done !
Upvotes: 2
Reputation: 4650
The official documentation has a section on cross compilation. Comparing that with what you are doing, there are two issues:
You specify i586-mingw32msvc-gcc and should specify i586-mingw32msvc-g++. The former is a C compiler, which is a bit tricky to use to compile C++ codebase ;-)
You need target-os=windows
Note that there's one known bug there -- when creating static libraries, they are not passed via ranlib, and mingw linker is specifically upset about this. You would have to run ranlib manually if you plan to use static libraries.
Upvotes: 10
Reputation: 9801
This is not really an answer, but: don't!
Cross compiling to a completely different platform is usually a huge pain in the ****.
If you are trying to build the windows binaries on the same machine, say for packaging, use a virtual machine with windows, mingw and appropriate scripts.
Then you can even run automated tests on the vm etc. with your build, which should be a huge advantage.
Upvotes: -3
Reputation: 11084
Boost makes assumptions about your OS and current build based on your current system. What if you were to get ahold of the win32 header files, remove all linux headers from the include path, and then try building?
Upvotes: 0