即使在链接后也能提高对系统的"Undefined Reference"
Boost "Undefined Reference" to system even after linking
我在eclipse cdt窗口中的boost中包含了以下库。
- libboost_filesystem-vc100-mt-1_51
- libboostrongystem-vc100-mt-1_51
从律师输出的顶部(下面)看,他们似乎联系得很好。然而,我犯了以下错误。
顾问输出/错误:
18:10:00 **** Incremental Build of configuration Debug for project Boost ****
Info: Internal Builder is used for build
g++ "-LC:\Users\Mike\Desktop\Lib\boost_1_51_0\stage\lib" -o Boost.exe "src\Boost.o" -llibboost_filesystem-vc100-mt-1_51 -llibboost_system-vc100-mt-1_51
srcBoost.o: In function `_static_initialization_and_destruction_0':
C:/Users/Mike/Desktop/Lib/boost_1_51_0/boost/system/error_code.hpp:214: undefined reference to `boost::system::generic_category()'
C:/Users/Mike/Desktop/Lib/boost_1_51_0/boost/system/error_code.hpp:215: undefined reference to `boost::system::generic_category()'
C:/Users/Mike/Desktop/Lib/boost_1_51_0/boost/system/error_code.hpp:216: undefined reference to `boost::system::system_category()'
srcBoost.o: In function `ZN5boost10filesystem9file_sizeERKNS0_4pathE':
C:/Users/Mike/Desktop/Lib/boost_1_51_0/boost/filesystem/operations.hpp:447: undefined reference to `boost::filesystem::detail::file_size(boost::filesystem::path const&, boost::system::error_code*)'
srcBoost.o: In function `path<char [9]>':
C:/Users/Mike/Desktop/Lib/boost_1_51_0/boost/filesystem/path.hpp:139: undefined reference to `boost::filesystem::path::codecvt()'
srcBoost.o: In function `ZN5boost10filesystem11path_traits8dispatchISbIwSt11char_traitsIwESaIwEEEEvRKSsRT_RKSt7codecvtIwciE':
C:/Users/Mike/Desktop/Lib/boost_1_51_0/boost/filesystem/path_traits.hpp:174: undefined reference to `boost::filesystem::path_traits::convert(char const*, char const*, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >&, std::codecvt<wchar_t, char, int> const&)'
collect2: ld returned 1 exit status
由此看来,系统库没有正确连接/链接。
我的代码:
#include <boost/filesystem.hpp>
#include <iostream>
#include <iterator>
#include <algorithm>
int main()
{
using namespace boost::filesystem;
file_size("test.txt");
return 0;
}
我是不是错过了什么?我需要包括其他内容吗?
每个C++编译器都有自己的规则和函数名篡改的实现(将C++函数名转换为ASM或类C函数)
例如,MSVC将boost::system::generic_category转换为?generic_category@system@助推@@YAABVerror_category@12@XZ,但在这种情况下,您使用的是一个DLL,该DLL是使用带有eclipse g++编译器的MSVC2010(vc100)构建的,该编译器具有不同的名称篡改规则,因此它期望在库中找不到其他内容,并生成链接器错误
一般来说,使用DLL中的C++对象是不合法的,该DLL是从与您在项目中使用的编译器不同的编译器编译的,甚至使用使用以前版本编译器编译的DLL也是不合法的。这就是boost将vc100添加到其DLL名称中以通知您只应将其与vc100(MSVC2010)一起使用的原因
相关文章:
- C++,系统无法执行指定的程序
- 在UNIX系统中使用DIR查找文件的字节大小
- 我的项目不会像"undefined reference to `grpc::g_core_codegen_interface'"那样使用未定义的引用错误进行编译
- Visual Studio Code "undefined reference to `WinMain@16'"
- 错误处理.将系统错误代码映射到泛型
- 当系统的卷被修改时,如何修改WASAPI环回捕获卷
- 有什么好的方法可以让系统调用代理允许在单元测试中进行模拟
- 使用 MATLAB 编码器生成C++代码:编译错误"undefined reference to `rgb2gray_tbb_real64'"
- 在C++游戏中与库存系统作斗争
- 文件系统:复制功能的速度秘诀是什么
- c++17文件系统::recursive_directory迭代器()在mac上没有给出这样的目录,但在windows上
- 在gtest.中使用fff.h模拟系统API
- "Undefined class"作为is_base_of的论据
- 为什么创建友元类的实例会导致"undefined reference to"错误?
- 如何制作无限制照明系统
- 系统.将数组移交给c#中动态加载的c++DLL时发生AccessViolationException
- 如何传递多个 std::文件系统选项?
- 遍历顺序由 std::文件系统directory_iterator给出
- C++系统找不到指定的文件错误
- 即使在链接后也能提高对系统的"Undefined Reference"