2011-09-09 59 views
2

我刚换我的dev的机器从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 

整个源是在GitHub上:https://github.com/robertseaton/slug

+0

你链接到'OpenSSL'吗? –

回答

8

看起来你错过-lcrypto

5

从我的经验,-lssl-lcrypto位置可能是问题的根源。尝试将-lcrypto选项推到gcc选项的末尾,或在输入对象文件之前。

相关问题