I have an issue with Mingw and boost. I use a cygwin environment
#include <boost/thread.hpp>
#include <cmath>
int main(){ return 0; }
If I compile with this command I get the following error
i686-pc-mingw32-g++ -std=c++11 test.cpp -o test.o
test.cpp:1:28: fatal error: boost/thread.hpp: No such file or directory
And if I include /usr/include
to get boost/thread.hpp, the wrong cmath header seem to be included:
i686-pc-mingw32-g++ -std=c++11 -I/usr/include test.cpp -o test.o
In file included from /usr/lib/gcc/i686-pc-mingw32/4.7.3/include/c++/random:38:0,
from /usr/lib/gcc/i686-pc-mingw32/4.7.3/include/c++/bits/stl_algo.h:67,
from /usr/lib/gcc/i686-pc-mingw32/4.7.3/include/c++/algorithm:63,
from /usr/include/boost/smart_ptr/shared_ptr.hpp:42,
from /usr/include/boost/shared_ptr.hpp:17,
from /usr/include/boost/date_time/time_clock.hpp:17,
from /usr/include/boost/thread/thread_time.hpp:9,
from /usr/include/boost/thread/win32/thread_data.hpp:10,
from /usr/include/boost/thread/thread.hpp:15,
from /usr/include/boost/thread.hpp:13,
from test.cpp:1:
/usr/lib/gcc/i686-pc-mingw32/4.7.3/include/c++/cmath:1046:11: error: '::acoshl' has not been declared
/usr/lib/gcc/i686-pc-mingw32/4.7.3/include/c++/cmath:1050:11: error: '::asinhl' has not been declared
/usr/lib/gcc/i686-pc-mingw32/4.7.3/include/c++/cmath:1054:11: error: '::atanhl' has not been declared
....
What can I do here ?
Mingw and cygwin are two different platforms. Cygwin is a POSIX-conform platform and supports many commands that can also be found on most UNIX platforms. mingw, on the other hand, is a target-platform to compile "pure" windows applications, usually used as a cross-compiler from a posix environment (like in your case: cygwin) to generate Windows binaries. Trying to use cygwin's version of boost while creating a mingw binary is similar to using the linux version of boost when compiling for Mac OS X. You wouldn't expect that to work either.
To install a mingw version of boost simply download and unpack boost. Invoke the following in the boost source directory:
./bootstrap.sh
Now edit the file project-config.jam
and change the line starting with using gcc
to:
using gcc : : i686-pc-mingw32-g++ ;
then invoke:
./bjam --prefix=/usr/i686-pc-mingw32/usr --layout=system variant=release threading=multi link=shared runtime-link=shared toolset=gcc target-os=windows threadapi=win32 stage
./bjam --prefix=/usr/i686-pc-mingw32/usr --layout=system variant=release threading=multi link=shared runtime-link=shared toolset=gcc target-os=windows threadapi=win32 install
The prefix /usr/i686-pc-mingw32/usr
may be wrong on your setup, so check that it exists. Also change the values of threading=multi link=shared runtime-link=shared
to your needs.
You can also find useful comments at Boost - cross compile - "from Linux" "to Windows"
Also, do not forget to remove -I/usr/include
as this will make gcc just use cygwin's version of boost again.