views:

1080

answers:

4

Hello,

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

A: 

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?

Kieveli
+2  A: 

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.

AndreasT
this is not acceptable
Matt Joiner
Well it works. "Acceptable" or not.
AndreasT
+3  A: 

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.

Vladimir Prus
I tried it with "i586-mingw32msvc-g++" and "target-os=windows" but nothing has been built and I got next 20 lines of errors.It seems that I will have to build the libraries from "Windows" (or another solution?).
Petike
Let me try to nail down what I did more precisely. I have SVN HEAD or Boost, and I have this in my user-config.jam:"using gcc : m : i586-mingw32msvc-g++ ;". I then run: "bjam toolset=gcc-m target-os=windows variant=debug --with-program_options". I see commands run, and eventually, stage/lib/libboost_program_options.lib is created. Can you try to do exactly the same? If it works, then please provide the errors you get on your usage. If it does not work, then also provide errors. I imagine errors won't fit on SO, so use http://codepad.org
Vladimir Prus
It finally works for me.I was wrong, I have only tried to compile the "thread" library and not "all". And thread couldn't be compiled because it couldn't find "pthreads". I only added:"threadapi=win32" and after that it was ok.So the whole command is:"./bjam --layout=system variant=release threading=multi link=shared runtime-link=shared toolset=gcc target-os=windows threadapi=win32 stage".But I still cannot compile these libraries:-graph-graph_parallel-iostreams-math (partly)-pythonThe others can be compiled.
Petike
Do you need all of those other libraries? If not, use --without-xxx to disable building them. I think that all of them, except for math, require additional third-party components, and you should only bother installing them if necessary.
Vladimir Prus
+1  A: 

There is a very simple procedure to follow to cross build boost from linux to windows here : http://www.vle-project.org/wiki/Cross_compilation_Win32

Elthariel