尝试在代码块上使用Boost库提供了未定义的参考

问题描述 投票:0回答:1

我正在尝试在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

谢谢!

c++ boost codeblocks libraries undefined-reference
1个回答
0
投票

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

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

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

© www.soinside.com 2019 - 2024. All rights reserved.