开发者

What causes this link failure (undefined reference)?

开发者 https://www.devze.com 2023-04-04 08:30 出处:网络
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:

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:

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.g开发者_高级运维old: 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.


Looks like you're missing -lcrypto


From my experience, the location of -lssl or -lcrypto may be the source of the problem. Try to push -lcrypto option to the end of the gcc options, or before input object files.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号