首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >基于明威的Boost路径夹杂困境

基于明威的Boost路径夹杂困境
EN

Stack Overflow用户
提问于 2013-08-06 12:57:02
回答 1查看 881关注 0票数 1

我对明和博斯有意见。我使用的是cygwin环境

代码语言:javascript
复制
#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

代码语言:javascript
复制
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
....

我在这里能做什么?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-11-19 16:52:50

明和赛根是两个不同的平台。Cygwin是一个符合POSIX的平台,支持在大多数UNIX平台上也可以找到的许多命令。另一方面,mingw是编译“纯”windows应用程序的目标平台,通常用作来自posix环境(如您的例子: cygwin)的交叉编译器来生成Windows二进制文件。在为Mac编译时,尝试使用cygwin的boost版本,同时创建一个混合二进制文件,类似于使用linux版本的boost。

要安装一个混合版本的boost,只需下载和解压boost。在boost源目录中调用以下内容:

代码语言:javascript
复制
./bootstrap.sh

现在编辑文件project-config.jam并将以using gcc开头的行更改为:

代码语言:javascript
复制
using gcc : : i686-pc-mingw32-g++ ;

然后调用:

代码语言:javascript
复制
./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。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18080859

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档