【问题标题】:Boost path inclusions dilemma with Mingw使用 Mingw 提升路径包含困境
【发布时间】:2013-08-06 12:57:02
【问题描述】:

我对 Mingw 和 boost 有疑问。我用的是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/thread.hpp,则似乎包含错误的 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
....

我可以在这里做什么?

【问题讨论】:

    标签: c++ boost cygwin mingw boost-thread


    【解决方案1】:

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

    要安装 mingw 版本的 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"找到有用的cmets

    另外,不要忘记删除-I/usr/include,因为这会使 gcc 再次使用 cygwin 的 boost 版本。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-11
      相关资源
      最近更新 更多