使用哪个版本的 libstdc++.so.6?
我在 Solaris 上使用第三方共享库 (libsw_api.so),当我尝试加载该库时,会产生以下错误:
fatal: relocation error: file libsw_api.so:
symbol _ZNKSt9bad_alloc4whatEv: referenced symbol not found
The program exited with error code 1
当我在 libsw_api.so 上运行 ldd 时,所有引用似乎都已满足,特别是 C++ 标准库指向 libstdc++.so.6.0.3:
glispa02(fostopr)$ ldd libsw_api.so
...
libstdc++.so.6 => /usr/sfw/lib/libstdc++.so.6
...
glispa02(fostopr)$ ls -l /usr/sfw/lib/libstdc++.so.6
lrwxrwxrwx 1 root root 18 Jun 21 2010 /usr/sfw/lib/libstdc++.so.6 -> libstdc++.so.6.0.3
但是该库不导出 _ZNKSt9bad_alloc4whatEv,
glispa02(fostopr)$ nm /usr/sfw/lib/libstdc++.so.6 | grep bad_alloc
[7592] | 752340| 64|FUNC |GLOB |0 |2653 |_ZNSt9bad_allocD0Ev
[7324] | 752284| 56|FUNC |GLOB |0 |2652 |_ZNSt9bad_allocD1Ev
[8077] | 752228| 56|FUNC |GLOB |0 |2651 |_ZNSt9bad_allocD2Ev
[7519] | 356736| 76|FUNC |GLOB |0 |473 |_ZSt17__throw_bad_allocv
[7341] | 983588| 12|OBJT |WEAK |0 |3842 |_ZTISt9bad_alloc
[6569] | 777008| 13|OBJT |WEAK |0 |3317 |_ZTSSt9bad_alloc
[7299] | 983568| 20|OBJT |WEAK |0 |3841 |_ZTVSt9bad_alloc
可能是什么问题?版本错误?我不太擅长 Unix 上的 C++,所以我会感谢任何帮助。
SPARC32PLUS 与 SPARC 不匹配是否是导致问题的原因?
glispa02(fostopr)$ file libsw_api.so
libsw_api.so: ELF 32-bit MSB dynamic lib SPARC32PLUS Version 1, V8+ Required, dynamically linked, not stripped
glispa02(fostopr)$ file /usr/sfw/lib/libstdc++.so.6.0.3
/usr/sfw/lib/libstdc++.so.6.0.3: ELF 32-bit MSB dynamic lib SPARC Version 1, dynamically linked, not stripped, no debugging information available
我的系统:
glispa02(fostopr)$ cat /etc/release
Solaris 10 10/09 s10s_u8wos_08a SPARC
Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
Use is subject to license terms.
Assembled 16 September 2009
glispa02(fostopr)$ uname -a
SunOS glispa02 5.10 Generic_141444-09 sun4u sparc SUNW,SPARC-Enterprise
I'm using a third party shared library (libsw_api.so) on Solaris, which when I try to load, produces the following error:
fatal: relocation error: file libsw_api.so:
symbol _ZNKSt9bad_alloc4whatEv: referenced symbol not found
The program exited with error code 1
When I run ldd on libsw_api.so, all references seem to be fulfilled, specifically the C++ standard library which points to libstdc++.so.6.0.3:
glispa02(fostopr)$ ldd libsw_api.so
...
libstdc++.so.6 => /usr/sfw/lib/libstdc++.so.6
...
glispa02(fostopr)$ ls -l /usr/sfw/lib/libstdc++.so.6
lrwxrwxrwx 1 root root 18 Jun 21 2010 /usr/sfw/lib/libstdc++.so.6 -> libstdc++.so.6.0.3
However that library does not export _ZNKSt9bad_alloc4whatEv,
glispa02(fostopr)$ nm /usr/sfw/lib/libstdc++.so.6 | grep bad_alloc
[7592] | 752340| 64|FUNC |GLOB |0 |2653 |_ZNSt9bad_allocD0Ev
[7324] | 752284| 56|FUNC |GLOB |0 |2652 |_ZNSt9bad_allocD1Ev
[8077] | 752228| 56|FUNC |GLOB |0 |2651 |_ZNSt9bad_allocD2Ev
[7519] | 356736| 76|FUNC |GLOB |0 |473 |_ZSt17__throw_bad_allocv
[7341] | 983588| 12|OBJT |WEAK |0 |3842 |_ZTISt9bad_alloc
[6569] | 777008| 13|OBJT |WEAK |0 |3317 |_ZTSSt9bad_alloc
[7299] | 983568| 20|OBJT |WEAK |0 |3841 |_ZTVSt9bad_alloc
What could be the problem? Wrong version? I'm not really good with C++ on Unix so I'ld appreciate any help.
Could this SPARC32PLUS vs. SPARC mismatch be the cause of the problem?
glispa02(fostopr)$ file libsw_api.so
libsw_api.so: ELF 32-bit MSB dynamic lib SPARC32PLUS Version 1, V8+ Required, dynamically linked, not stripped
glispa02(fostopr)$ file /usr/sfw/lib/libstdc++.so.6.0.3
/usr/sfw/lib/libstdc++.so.6.0.3: ELF 32-bit MSB dynamic lib SPARC Version 1, dynamically linked, not stripped, no debugging information available
My system:
glispa02(fostopr)$ cat /etc/release
Solaris 10 10/09 s10s_u8wos_08a SPARC
Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
Use is subject to license terms.
Assembled 16 September 2009
glispa02(fostopr)$ uname -a
SunOS glispa02 5.10 Generic_141444-09 sun4u sparc SUNW,SPARC-Enterprise
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您好,我也在升级这些文件,我注意到我应该使用发行版附带的 libstdc++.so.6.0.9 文件,而不是 /usr/sfw/lib/ 中的文件
Hi I'm also upgrading these files, I noticed that I should be using the libstdc++.so.6.0.9 file that comes with the distribution rather than the one in /usr/sfw/lib/
如果您在
libstdc++.so.6
文件上使用 pvs,它会给您一堆匹配的条目:GLIBCXX
,如果您没有匹配的条目>GLIBCXX_3.4.9
,则符号bad_alloc::what
不在该库中,即该库早于依赖对象libsw_api.so
如果这是在这种情况下,您可能需要更新版本的 libstdc++ - 它会附带更新版本的 g++
If you use pvs on the
libstdc++.so.6
file, it will give you a bunch of entries matching:GLIBCXX
, if you don't have an entry matchingGLIBCXX_3.4.9
, then the symbolbad_alloc::what
is not in that library i.e. the library is older than the dependent objectlibsw_api.so
If this is the case then you probably need a newer version of libstdc++ - it would come with a newer version of g++
我遇到同样的问题。
原因是我们导出了错误的LD_LIBRARY_PATH
这样我们的共享库就会链接到原始 gcc 的库 (3.3),而不是我们的编译器 (gcc 4.4)。
修复链接器问题应该可以解决问题
I encounter the same issue.
The cause is we export the wrong LD_LIBRARY_PATH
So that our shared library link to the original gcc's library (3.3) instead of our compiler (gcc 4.4).
Fix the linker problem should solve the issue