使用 <experimental/filesystem> 和调用函数的链接器错误
Linker error using <experimental/filesystem> and calling a function
我正在尝试使用实验性 c++ 文件系统编译程序,但在尝试 link 我的程序时遇到了奇怪的行为。我可以创建 fs::path,但调用任何函数都会导致 link 错误。
我正在 Windows 10 上使用 g++.exe(i686-posix-dwarf,由 MinGW-W64 项目构建)6.1.0.
进行编译
编译以下代码:
namespace fs = std::experimental::filesystem::v1;
bool utl::doesExist(const std::string& fileLocation)
{
fs::path path(fileLocation);
std::cout << path << std::endl;
return true;
}
但是,当尝试使用任何函数时,我都会遇到同样的错误
bool utl::doesExist(const std::string& fileLocation)
{
fs::path path(fileLocation);
return fs::exists(fileLocation);
}
生成文件:
CC = g++
CFLAGS = -std=c++11 -MP -MD -fPIC
OUTPUT:
g++ build/Engine.o ... -o bin/libquestia-eng.1.0.0.dll -L lib/SFML-2.4.2-win/lib -lsfml-audio -lsfml-network -lsfml-graphics -lsfml-window -lsfml-system -lstdc++fs -shared
错误:
C:/MinGW/bin/../lib/gcc/i686-w64-mingw32/6.1.0/libstdc++fs.a(ops.o):(.text$_Z10_wrealpathPKwPw+0x68): undefined reference to `CreateTransaction@28'
C:/MinGW/bin/../lib/gcc/i686-w64-mingw32/6.1.0/libstdc++fs.a(ops.o):(.text$_Z10_wrealpathPKwPw+0x121): undefined reference to `CommitTransaction@4'
我认为问题可能在于目标是一个dll,但是在互联网上搜索没有为我提供解决方案。关于这个 linker 错误的含义有什么想法吗?
看起来有一个 windows 您需要 link 的库,但不会自动包含该库。 linker 找不到的符号 CreateTransaction
和 CommitTransaction
位于 KtmW32.dll
中,因此您需要包含对 KtmW32.lib
的引用.
我正在尝试使用实验性 c++ 文件系统编译程序,但在尝试 link 我的程序时遇到了奇怪的行为。我可以创建 fs::path,但调用任何函数都会导致 link 错误。
我正在 Windows 10 上使用 g++.exe(i686-posix-dwarf,由 MinGW-W64 项目构建)6.1.0.
进行编译编译以下代码:
namespace fs = std::experimental::filesystem::v1;
bool utl::doesExist(const std::string& fileLocation)
{
fs::path path(fileLocation);
std::cout << path << std::endl;
return true;
}
但是,当尝试使用任何函数时,我都会遇到同样的错误
bool utl::doesExist(const std::string& fileLocation)
{
fs::path path(fileLocation);
return fs::exists(fileLocation);
}
生成文件:
CC = g++
CFLAGS = -std=c++11 -MP -MD -fPIC
OUTPUT:
g++ build/Engine.o ... -o bin/libquestia-eng.1.0.0.dll -L lib/SFML-2.4.2-win/lib -lsfml-audio -lsfml-network -lsfml-graphics -lsfml-window -lsfml-system -lstdc++fs -shared
错误:
C:/MinGW/bin/../lib/gcc/i686-w64-mingw32/6.1.0/libstdc++fs.a(ops.o):(.text$_Z10_wrealpathPKwPw+0x68): undefined reference to `CreateTransaction@28'
C:/MinGW/bin/../lib/gcc/i686-w64-mingw32/6.1.0/libstdc++fs.a(ops.o):(.text$_Z10_wrealpathPKwPw+0x121): undefined reference to `CommitTransaction@4'
我认为问题可能在于目标是一个dll,但是在互联网上搜索没有为我提供解决方案。关于这个 linker 错误的含义有什么想法吗?
看起来有一个 windows 您需要 link 的库,但不会自动包含该库。 linker 找不到的符号 CreateTransaction
和 CommitTransaction
位于 KtmW32.dll
中,因此您需要包含对 KtmW32.lib
的引用.