尝试在cygwin中构建boost文件系统时出错:错误:在'&&&'之前预期不合格的id代币

时间:2016-10-13 12:39:09

标签: c++ boost

我安装了cygwin 2.6 gcc 5.4。我安装了boost.build,它似乎正在运行。但是,当我尝试构建文件系统模块时,它失败并显示错误:

work@PC /lib/boost_1_62_0/libs/filesystem/example/test
$ ./build.sh
Compiling example programs...
tut4.cpp:40:18: error: expected unqualified-id before '&&' token
tut4.cpp:40:18: error: expected ';' before '&&' token
tut4.cpp:40:23: error: expected ';' before ':' token
tut4.cpp:40:23: error: expected primary-expression before ':' token
tut4.cpp:40:23: error: expected ')' before ':' token
tut4.cpp:40:23: error: expected primary-expression before ':' token
tut4.cpp:45:18: error: expected unqualified-id before '&&' token
tut4.cpp:45:18: error: expected ';' before '&&' token
tut4.cpp:45:23: error: expected ';' before ':' token
tut4.cpp:45:23: error: expected primary-expression before ':' token
tut4.cpp:45:23: error: expected ')' before ':' token
tut4.cpp:45:23: error: expected primary-expression before ':' token
tut4.cpp:40:21: error: label 'x' used but not defined
../../../../boost/system/error_code.hpp: At global scope:
../../../../boost/system/error_code.hpp:221:36: warning: 'boost::system::posix_category' defined but not
 used [-Wunused-variable]
     static const error_category &  posix_category = generic_category();
../../../../boost/system/error_code.hpp:222:36: warning: 'boost::system::errno_ecat' defined but not use
d [-Wunused-variable]
     static const error_category &  errno_ecat     = generic_category();
../../../../boost/system/error_code.hpp:223:36: warning: 'boost::system::native_ecat' defined but not us
ed [-Wunused-variable]
     static const error_category &  native_ecat    = system_category();
path_info.cpp:41:13: error: 'element' does not name a type
path_info.cpp:44:3: error: expected ';' before 'cout'
path_info.cpp:49:62: error: expected ')' before ';' token
../../../../boost/system/error_code.hpp: At global scope:
../../../../boost/system/error_code.hpp:221:36: warning: 'boost::system::posix_category' defined but not
 used [-Wunused-variable]
     static const error_category &  posix_category = generic_category();
../../../../boost/system/error_code.hpp:222:36: warning: 'boost::system::errno_ecat' defined but not use
d [-Wunused-variable]
     static const error_category &  errno_ecat     = generic_category();
../../../../boost/system/error_code.hpp:223:36: warning: 'boost::system::native_ecat' defined but not us
ed [-Wunused-variable]
     static const error_category &  native_ecat    = system_category();

我该怎么做才能解决这个问题?

我在b2中安装/usr/local/并在boost-build.jam内设置/usr/local/share/boost-build以获得这些值:

# Copyright 2001, 2002 Dave Abrahams
# Copyright 2002 Rene Rivera
# Copyright 2003 Vladimir Prus
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)


boost-build src/kernel ;
using gcc : 5.4 : g++-5.4 : <cxxflags>=c++11 ;  // Could it be that this settings is wrong or not applying during compilation?

我试图按照来自official boost docs的说明,这说明我应该这样:

$ cd boost-root/libs/filesystem/example/test

$ ./setup.sh
Copying example programs...

$ ./build.sh
Compiling example programs...

$ ./tut1
Usage: tut1 path

1 个答案:

答案 0 :(得分:1)

您的问题是由于您尝试在没有C++11支持的情况下构建代码而引起的,正如评论中已经提到的那样。

我不是boost专家,所以实际上无法说明为什么jam文件中的设置不适用以及在boost env中解析此类设置的正确顺序是什么我更喜欢自己编写命令。但是,如果有人能用*.jam文件解释你的错误,那将是非常好的。

但要解决问题,请使用以下内容:

b2 toolset=gcc cxxflags="-std=c++11" $* > build.log代替./build.sh,您的项目将按预期编译。

相关问题