Boost filesystem Symbol not found C++ VS Code

69 views Asked by At

I'm a hobbyist coder trying to use Boost so I can work with files and I keep getting a weird error:

dyld[70964]: Symbol not found: __ZN5boost10filesystem6detail6statusERKNS0_4pathEPNS_6system10error_codeE
  Referenced from: <D67FA2B8-D2CA-381C-98F1-3E8E006E3984> /Users/dmonti/Documents/Code/TestProj2/main
  Expected in:     <no uuid> unknown

I am using C++ on Visual Studio Code on Mac M1 Ventura 13.5.1.

I followed this to download, unpack and build the libraries: https://www.boost.org/doc/libs/1_84_0/more/getting_started/unix-variants.html

Using these terminal commands:

./bootstrap.sh
./b2

In my tasks.json file I included the header path, library path and libraries:

{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: clang++ build active file",
            "command": "/usr/bin/clang++",
            "args": [
                "-fcolor-diagnostics",
                "-fansi-escape-codes",
        "-I/Users/dmonti/Documents/Code/lib/boost_1_82_0",
        "-L/Users/dmonti/Documents/Code/lib/boost_1_82_0/stage/lib",
        "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}",
        "-lboost_system",
        "-lboost_filesystem",
        ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "Task generated by Debugger."
        }
    ],
    "version": "2.0.0"
}

My folder contains only a main.cpp in terms of source code:

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

int main(int argc, char *argv[]) {
    namespace fs = boost::filesystem;

    fs::path p = fs::path("text.txt");
    if(fs::is_regular_file(p)) 
        std::cout<<"File"<<std::endl;
    else if(fs::is_directory(p))
        std::cout<<"Dir"<<std::endl;
    else 
        std::cout<<"Something else."<<std::endl;
    return 0;
 }

Any help on this would be greatly appreciated!

Dean

0

There are 0 answers