boostorg/filesystem

boost::filesystem::exist link error using clang-cl toolset.

haydenzhourepo opened this issue · 1 comments

env

OS: Windows 11
boost version: 1.83.0
LLVM version: 17.0.1

How to reproduce

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

//namespace fs = std::filesystem;
namespace fs = boost::filesystem;

int main()
{
    fs::path path("abc");
    if (fs::exists(path)) {
        std::cout << "found!\n";
    }
    else {
        std::cout << "not found!\n";
    }
}

compile the code above by the clang-cl toolset. will throw lld-link error.
if I changed to use std::filesystem, then the codes compile succeed.

error

image
image

Apparently, auto-linking doesn't work in your configuration. I think, some versions of clang-cl didn't support it, but I don't know which. Or you may be defining BOOST_ALL_NO_LIB or BOOST_FILESYSTEM_NO_LIB somewhere, which disables auto-linking.

Without auto-linking, you need to explicitly specify Boost libraries in your linker command line, in your project settings.