排除编译时链接错误
在使用新的工具链从源代码构建后,我尝试静态链接到 libcrypto.a (来自 openssl 库)。然而,每当我尝试使用该库中的任何函数时,我都会收到“未定义的引用”错误。我已确保包含正确的头文件。我还仔细检查了 libcrypto.a 的符号表并确保这些函数确实已定义。
我还能做些什么来调试这个错误 - 比如从链接器中获取更多信息或检查 libcrypto.a 本身,以找出为什么当指示的符号出现在符号中时链接器会吐出“未定义的引用”错误桌子?
I'm trying to statically link to libcrypto.a (from the openssl library) after building it from source with a new toolchain. However whenever I try to use any of the functions from that library, I keep receiving "undefined reference" errors. I've made sure the right header file was included. I've also double checked the symbol table of libcrypto.a and made sure these functions are indeed defined.
Is there anything else I can do to debug this error- like getting more info out of the linker or examining libcrypto.a itself, to find out why the linker is spitting out "undefined reference" error when the indicted symbols shows up in the symbol table?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
未定义的引用/符号是链接器错误,指示链接器在任何正在链接的目标模块中找不到指定的符号。这表示以下一项或多项:
Undefined reference/symbol is a linker error indicating that the linker can't find the specified symbol in any of the object modules being linked. This indicates one or more of the following:
我看到您的帖子被标记为
c++
。 OpenSSL 是用 C 语言编写的。您记得吗
?
I see your post is tagged
c++
. OpenSSL is written in C.Did you remember to do
?
使用 nm grep 从 libcrypto 中取出符号,
以便您可以查看它是否存在 - 可能不存在(duh)
ssl 有 2 个库,也许您使用了错误的库,
缺少的符号到底是什么
grep the symbol out of libcrypto using nm
so you can see if its there - probably not (duh)
ssl has 2 libs , maybe you are using the wrong one
what exectly is the missing symbol