c++ - 尝试在 Codeblocks 上使用 Boost 库会给出未定义的引用

标签 c++ boost codeblocks libraries undefined-reference

我正在尝试在 CodeBlocks 上使用 boost 库,但我是新手,我似乎无法正确链接它。

boost文件夹(1.70版)与我的main.cpp在同一个文件夹中,我试图访问的库是libboost_filesystem-mgw92-mt-x64-1_70.a;

这是我的代码:

#include <iostream>
#include <boost/filesystem.hpp>


int main()
{

    boost::filesystem::path l_path("C:\\Hello.txt");
    if(boost::filesystem::exists(l_path))
        {
        std::cout<<"exists!"<<std::endl;
        }
        else
        {
        std::cout<<"no";
        }
    return 0;
}

还有一些我的设置和错误的截图

The linker settings

The search Directories for compiler an linker(both the same)

And a screenshot of the error

谢谢!

最佳答案

对 _Unwind_Resume 的 undefined reference 建议您使用与项目不同的编译器构建 Boost,或者选择不同类型的异常处理。

检查您是否在两种情况下都使用相同的编译器。

这也可能是由于使用 gcc 而不是 g++ 构建项目造成的。你也应该检查一下。在这种情况下,通过添加 -lstdc++ 切换到 g++ 或显式链接到 libstdc++到编译器标志。

关于c++ - 尝试在 Codeblocks 上使用 Boost 库会给出未定义的引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59542373/

相关文章:

c++ - 如何在 winpcap 库中使用 pcap_sendqueue_queue()?

c++ - 动态添加对象?

c++ - 关于我应该使用的加密方法的建议

c++ - C++ 中简单的类型驱动随机模型构造

c++ - 为什么 map 上的 BOOST_FOREACH 仅适用于 typedef

c++ - 构建 wxWidgets 应用程序失败 - 未定义对 `wxCRT_StrdupA(char const*)' 的引用

C 编程 : Codeblocks stops working with C till I make a tiny change. 知道为什么吗?

c++ - 如何将类(class)的公共(public)成员设为私有(private)?

c++ - 如何识别boost fusion vector 中的类型

compiler-errors - 设置代码::Blocks to compile MPI programs with MPICC.exe