简体   繁体   English

导致此链接失败的原因(未定义的引用)?

[英]What causes this link failure (undefined reference)?

I just switched my dev machine from Gentoo to Arch Linux and, when I try to compile a fresh build of my project, linking fails: 我刚刚将我的开发机器从Gentoo切换到Arch Linux,当我尝试编译我的项目的新版本时,链接失败:

clang -O0 -g -pipe -Wall -DDEBUG -o slug announce.o bitfield.o main.o metadata.o network.o parser.o peer.o piece.o scheduler.o torrent.o url.o util.o -I. -lssl -lm -lcurl -levent
/usr/bin/ld.gold: metadata.o: in function get_info_hash:metadata.c:186: error: undefined reference to 'SHA1_Init'
/usr/bin/ld.gold: metadata.o: in function get_info_hash:metadata.c:187: error: undefined reference to 'SHA1_Update'
/usr/bin/ld.gold: metadata.o: in function get_info_hash:metadata.c:188: error: undefined reference to 'SHA1_Final'
/usr/bin/ld.gold: piece.o: in function verify_piece:piece.c:40: error: undefined reference to 'SHA1_Init'
/usr/bin/ld.gold: piece.o: in function verify_piece:piece.c:41: error: undefined reference to 'SHA1_Update'
/usr/bin/ld.gold: piece.o: in function verify_piece:piece.c:42: error: undefined reference to 'SHA1_Final'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [slug] Error 1

The entire source is on GitHub: https://github.com/robertseaton/slug . 整个源代码在GitHub上: https//github.com/robertseaton/slug

看起来你错过了-lcrypto

From my experience, the location of -lssl or -lcrypto may be the source of the problem. 根据我的经验, -lssl-lcrypto的位置可能是问题的根源。 Try to push -lcrypto option to the end of the gcc options, or before input object files. 尝试将-lcrypto选项推-lcrypto gcc选项的末尾,或者在输入对象文件之前。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM