'ld:找不到建筑???符号",即使它在那里
'ld: symbol(s) not found for architecture ???' even when it's there
我有这个奇怪的问题,试图在c++中添加一个boost模块的引用。首先,你需要知道我在玩一点c++,所以也许这是我错过的一个超级简单的新手的东西。
这是我的环境,所以你得到更多的上下文:Mac OS Mavericks,与MacPorts端口的boost 1.55和g++-mp-4.8。我目前正在链接和使用boost_system-mt
和boost_filesystem-mt
。
问题是我在一个正在进行的项目中工作,它一直使用boost并且编译得很好。我试图将utf8
字符串转换为Latin1
,因此我包括boost/locale.hpp
,并将-lboost_locale-mt
添加到链接器参数。对于我正在做的任务:
boost::locale::conv::from_utf<char>(value, "Latin1")
到目前为止,它编译得很好,但是当链接应该完成时,我得到以下错误:
Undefined symbols for architecture x86_64:
"std::basic_string<char, std::char_traits<char>, std::allocator<char> > boost::locale::conv::from_utf<char>(char const*, char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, boost::locale::conv::method_type)", referenced from:
clsByteQueue::WriteUnicodeStringFixed(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) in clsByteQueue.o
clsByteQueue::WriteUnicodeString(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) in clsByteQueue.o
ld: symbol(s) not found for architecture x86_64
链接器正在使用以下命令运行:
g++-mp-4.8 -fstack-protector -ggdb -o "bin/foobar" <all compiled.o files goes here> -L/opt/local/lib/ -levent -levent_core -levent_extra -lboost_system-mt -lboost_filesystem-mt -lboost_locale-mt
问题是,我检查了/opt/local/lib/libboost_locale-mt.a
不仅存在,而且还为正确的体系结构编译:
$ lipo -info /opt/local/lib/libboost_locale-mt.a
input file /opt/local/lib/libboost_locale-mt.a is not a fat file
Non-fat file: /opt/local/lib/libboost_locale-mt.a is architecture: x86_64
同样,我在文件中搜索from_utf,出现了以下符号:
$ otool -tv /opt/local/lib/libboost_locale-mt.a | grep from_utf
__ZN5boost6locale4conv8from_utfIcEENSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEEPKT_SC_RKS9_NS1_11method_typeE:
在使用c++filt
解开它之后,我可以验证链接器没有找到相同的符号(除非__1意味着什么?):
$ c++filt __ZN5boost6locale4conv8from_utfIcEENSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEEPKT_SC_RKS9_NS1_11method_typeE
std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > boost::locale::conv::from_utf<char>(char const*, char const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, boost::locale::conv::method_type)
所以,我现在几乎一无所知。
你们能帮我找出什么是错的,或者至少我可以尝试什么?
看起来你的boost::locale
是用clang和libc++编译的,这是Mac OS X的默认编译器和标准库,而你的程序是用g++和libstdc++编译的,这是g++的标准库。这两个标准库不兼容。
你需要用clang和libc++编译所有的东西,或者得到一个用g++和libstdc++编译的boost版本
相关文章:
- std::map<struct,struct>::find 找不到匹配项,但是如果我循环通过 begin() 到 end(),我在那里看到匹配项
- 是否可以在 c++ 中将两位数保存在无符号字符中
- scanf( "%d" , array[i] + 1)是什么意思?为什么+1在那里?
- 在有符号基础类型枚举的位域上溢出
- C++ csv 文件无法正确加载到矢量,它似乎知道对象在那里但不显示它们
- 是否可以将多个结构作为一个数据包存储在一个函数中,然后传递给其他函数并在那里提取?
- 在无符号字符数组中设置无符号短字符
- Fread C++ in C#.我知道我需要字节缓冲区,但并不完全在那里
- 链接 openGL 库失败,因为它无法打开 libgl.so ...但它就在那里
- C++:使用数组、指针和 for 循环制作直方图。我就在那里,我可能想得太辛苦了
- C++/Arduino:strcpy()、strncpy() 和 memcpy() 在无符号字符上不起作用
- 在平等符号左侧使用RVALUE参考的规则是什么?
- C 是否具有接口类概念,如果它在那里,那么它与Java接口类别有何不同
- CPP 如何在无符号整数值中使用布尔值?
- 为什么静态必须在那里
- "我"的意思,为什么在那里?
- 'ld:找不到建筑???符号",即使它在那里
- 奇怪的链接错误。找不到符号,尽管 nm 验证它在那里
- Android NDK链接V8静态库:找不到符号,但它们在那里
- GCC 和 ld 找不到导出的符号...但他们在那里