Atlas:undefined reference to `std::experimental::filesystem::v1::__cxx11::path::_M_split_cmpts()

1 问题现象

编写文件检测函数,对读取的文件,检测是否存在,

#include 
bool fileExists(const std::string fileName, bool verbose=true){
    if (!std::experimental::filesystem::exists(std::experimental::filesystem::path(fileName))){
        if (verbose){
            std::cout << "File does not exist : " << fileName << std::endl;
        }    
        return false;
    }
    return true;
}

在cmake与make后,出现如下问题:

CMakeFiles/yolo.dir/media/sf_share/WorkSpace_MZY/Demo_20211207/MZY_20211207_验证版本/yolo_cv_capture_yaml/mzy_feature/src_mzy/det_config_mzy.cpp.o: In function `std::experimental::filesystem::v1::__cxx11::path::path, std::allocator >, std::experimental::filesystem::v1::__cxx11::path>(std::__cxx11::basic_string, std::allocator > const&)':
det_config_mzy.cpp:(.text._ZNSt12experimental10filesystem2v17__cxx114pathC2INSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES3_EERKT_[_ZNSt12experimental10filesystem2v17__cxx114pathC5INSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES3_EERKT_]+0x68): undefined reference to `std::experimental::filesystem::v1::__cxx11::path::_M_split_cmpts()'
collect2: error: ld returned 1 exit status

查看:

undefined reference to `std::experimental::filesystem::v1::__cxx11::path::_M_split_cmpts()'

原因是由于cmakelist中对于库文件没有进行配置,添加如下:

# filesystem
target_link_libraries(yolo -lstdc++fs)

重新cmake与make编译,问题解除。

你可能感兴趣的:(Atlas,c++,cmake,ubuntu)