小编And*_*ian的帖子

在Travis CI上的Boost中对`std :: __ cxx11 :: basic_string的未定义引用

我正在尝试获得一个C+++项目,它在GitHub上使用Boost在Travis CI上正确编译.

首先我尝试了ubuntu上的软件包和PPA,但它们太旧了(我至少需要Boost 1.61).

只有当我在Travis CI(下载,编译)上编译Boost时才能使用它,但不幸的是,编译时间很长(11-18分钟)并且日志文件非常庞大.

考虑如何解决这个问题,我想到了编译我的机器上的提升,压缩,上传到某个Web服务器,只是下载并复制/ usr/local/[include/lib]相应的文件.

是我在我的机器上使用的编译器.我编译了boost使用

./bootstrap.sh --prefix=/home/andrei/boostabc
/usr/bin/time ./b2 install link=static
Run Code Online (Sandbox Code Playgroud)

是travis文件(和存储库).在评论中我是通过编译boost来实现的.

问题是我遇到了很多错误:

/usr/local/lib/libboost_filesystem.a(operations.o): In function `(anonymous namespace)::dir_itr_first(void*&, void*&, char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, boost::filesystem::file_status&, boost::filesystem::file_status&) [clone .isra.46] [clone .constprop.56]':
operations.cpp:(.text+0xa8): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_assign(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
Run Code Online (Sandbox Code Playgroud)

我搜索了这个错误,我发现可能存在关于某些C++ 11 ABI和宏的错误配置.我不太了解这个解释,我也不知道如何让它工作.

如果你能指出我正确的解决方向,我将不胜感激.

c++ gcc boost c++11 travis-ci

7
推荐指数
1
解决办法
1万
查看次数

设置一个可以使用和不使用预编译头进行编译的项目

我想要做的是设置一个项目,如果设置了预编译标头,则无关紧要.stdafx.hpp是我的PH

我的主要问题是我有多个目录上的文件,而不仅仅是项目根目录.我尝试了什么:

  1. 如果我

    #include "stdafx.hpp"
    
    Run Code Online (Sandbox Code Playgroud)

    PH设置无处不在,但如果我将其停用,它会抱怨,因为子目录中的文件无法找到它.

  2. 如果我

    #include "../stdafx.hpp"
    
    Run Code Online (Sandbox Code Playgroud)

    在子目录中的文件中,它在没有PH的情况下工作正常,但是对于PH,编译器抱怨stdafx.hpp没有包含它.

  3. 如果我stdafx.hpp使用相对或绝对路径设置强制包含文件,编译器给了我错误(现在不能记住,如果有必要我将重现它).

那么,可能是什么解决方案呢?

c++ precompiled-headers visual-studio visual-studio-2015

5
推荐指数
1
解决办法
151
查看次数

构建 boost - build.bat 未被识别为程序

我正在尝试构建 Boost 以使用文件系统库。

我知道我必须运行 bootstrap.bat (适用于 Windows)来创建 b2 应用程序,然后我应该运行它。

但我得到这个错误:

C:\Users\Andrei>D:\Info\include\boost_1_58_0\tools\build\bootstrap.bat
Bootstrapping the build engine
The system cannot find the path specified.
'.\build.bat' is not recognized as an internal or external command,
operable program or batch file.

Failed to bootstrap the build engine
Please consult bootstrap.log for furter diagnostics.
Run Code Online (Sandbox Code Playgroud)

我没有找到 build.bat 或日志文件..

我怎么解决这个问题 ?我读到我必须构建它才能获取文件系统库。这是真的吗?

非常感谢。

c++ boost

4
推荐指数
1
解决办法
6407
查看次数

std :: array和bytes read

我已经阅读了很多关于在C++中不使用C风格的东西,而是使用像std :: array,std :: vector或std :: string这样的容器.

现在我试图用文件流读取和写入小二进制文件并将其存储在std :: array中.

看起来std :: fstream的read和write方法只适用于C风格的数组......

所以这就是我的想法:

int main(int argc, char **argv)
{
    std::fstream testFile, outTestFile;
    testFile.open("D:/mc_svr/another/t/world/region/r.0.0.mca", std::fstream::in | std::fstream::binary);
    outTestFile.open("D:/mc_svr/another/t/world/region/xyz.xyz", std::fstream::out | std::fstream::binary);

    std::array<byte_t, 8192> testArray;

    testFile.read((char*) &testArray, 8192);
    outTestFile.write((char*) &testArray, 8192);

    testFile.close();
    outTestFile.close();

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

byte_t只是一个

typedef char byte_t;
Run Code Online (Sandbox Code Playgroud)

有用.但这是做这件事的好方法吗?如果不是,还有其他方法吗?我应该使用byte_t []吗?

c++ fstream c++11 stdarray

1
推荐指数
1
解决办法
2080
查看次数