C++ 为什么我的std::filesystem使用如此公开std::filesystem符号?

C++ 为什么我的std::filesystem使用如此公开std::filesystem符号?,c++,gcc,c++17,nm,C++,Gcc,C++17,Nm,我正在Linux上构建一个共享库,并已将该项目配置为使用-fvisibility=hidden和\uuuuuuuu属性((\uuuu visibility\uuuuuu(“默认”))手动添加到我要导出的符号中进行编译。以下虚拟文件足以说明: #包括 #包括 命名空间fs=std::实验::文件系统; __属性(可视性)void foo(默认值){std::cout我不相信你能解决这个问题。如果链接到你的库的其他库或可执行文件需要该库,那么它会想找到符号。我相信你唯一的选择是做一个静态链接,并使用

我正在Linux上构建一个共享库,并已将该项目配置为使用
-fvisibility=hidden
\uuuuuuuu属性((\uuuu visibility\uuuuuu(“默认”))
手动添加到我要导出的符号中进行编译。以下虚拟文件足以说明:

#包括
#包括
命名空间fs=std::实验::文件系统;

__属性(可视性)void foo(默认值){std::cout我不相信你能解决这个问题。如果链接到你的库的其他库或可执行文件需要该库,那么它会想找到符号。我相信你唯一的选择是做一个静态链接,并使用
-Wl,--exclude libs,所有的
嗯。这些符号仅供内部使用我希望任何链接都能得到它们自己的副本,这可能是一个心理错误,因为这听起来像是ODR冲突,但奇怪的是只有std::filesystem能做到这一点。
000000000003b110 T std::filesystem::__cxx11::directory_iterator::operator*() const
000000000003a930 T std::filesystem::__cxx11::recursive_directory_iterator::depth() const
000000000003a980 T std::filesystem::__cxx11::recursive_directory_iterator::operator*() const
0000000000034bb0 T std::filesystem::__cxx11::path::parent_path() const
0000000000032870 T std::filesystem::__cxx11::path::has_filename() const