Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Boost - cross compile - "from Linux" "to Windows"

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

like image 360
Petike Avatar asked Sep 09 '09 11:09

Petike


Video Answer


2 Answers

The official documentation has a section on cross compilation. Comparing that with what you are doing, there are two issues:

  1. 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 ;-)

  2. 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.

like image 70
Vladimir Prus Avatar answered Oct 30 '22 16:10

Vladimir Prus


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

like image 21
Elthariel Avatar answered Oct 30 '22 18:10

Elthariel