我对明和博斯有意见。我使用的是cygwin环境
#include <boost/thread.hpp>
#include <cmath>
int main(){ return 0; }如果使用此命令进行编译,则会得到以下错误
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
如果我添加了/usr/include来获取boost/线程. get,那么似乎包含了错误的cmath:
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
....我在这里能做什么?
发布于 2013-11-19 16:52:50
明和赛根是两个不同的平台。Cygwin是一个符合POSIX的平台,支持在大多数UNIX平台上也可以找到的许多命令。另一方面,mingw是编译“纯”windows应用程序的目标平台,通常用作来自posix环境(如您的例子: cygwin)的交叉编译器来生成Windows二进制文件。在为Mac编译时,尝试使用cygwin的boost版本,同时创建一个混合二进制文件,类似于使用linux版本的boost。
要安装一个混合版本的boost,只需下载和解压boost。在boost源目录中调用以下内容:
./bootstrap.sh现在编辑文件project-config.jam并将以using gcc开头的行更改为:
using gcc : : i686-pc-mingw32-g++ ;然后调用:
./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前缀/usr/i686-pc-mingw32/usr在您的设置中可能是错误的,所以请检查它是否存在。还可以将threading=multi link=shared runtime-link=shared的值更改为您的需要。
您还可以在Boost - cross compile - "from Linux" "to Windows"上找到有用的注释
另外,不要让忘记删除-I/usr/include,因为这将使gcc再次使用cygwin的版本boost。
https://stackoverflow.com/questions/18080859
复制相似问题