gpt4 book ai didi

c++ - 尝试在 cygwin : error: expected unqualified-id before '&&' token 中构建 boost 文件系统时出错

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:15:13 24 4
gpt4 key购买 nike

我安装了 cygwin 2.6gcc 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();

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


我在 /usr/local/ 中安装了 b2 并在 /usr/local/share 中设置了 boost-build.jam/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

最佳答案

你的问题是因为你试图在没有 C++11 支持的情况下构建你的代码,正如评论中已经提到的那样。

我不是 boost 专家,所以实际上无法说明为什么您的 jam 文件中的设置不适用以及解决此类问题的正确顺序是什么boost env 中的设置,因为我更喜欢自己编写命令。然而,如果有人能够用 *.jam 文件解释您的错误,那就太好了。

但要解决您的问题,只需使用类似的东西:

b2 toolset=gcc cxxflags="-std=c++11"$* > build.log 而不是 ./build.sh 你的项目将被编译正如预期的那样。

关于c++ - 尝试在 cygwin : error: expected unqualified-id before '&&' token 中构建 boost 文件系统时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40021262/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com