3

我正在尝试编译一个依赖于一些 SSL 库的 C 程序。当我尝试编译时,出现以下错误:

michael@michael-VirtualBox:~/$ cc -lssl -lcrypto iot.o tun2iot.o -o tun2iot
iot.o: In function `_iot_wfd_new':
iot.c:(.text+0x21b): undefined reference to `CRYPTO_malloc'
iot.o: In function `_iot_wfd_free':
iot.c:(.text+0x289): undefined reference to `CRYPTO_free'
iot.c:(.text+0x29d): undefined reference to `CRYPTO_free'
iot.o: In function `_iot_frame_ind':
iot.c:(.text+0x366): undefined reference to `CRYPTO_free'
iot.o: In function `_iot_error_ind':
iot.c:(.text+0x3f4): undefined reference to `CRYPTO_free'
iot.o: In function `_iot_do_phase_connect':
iot.c:(.text+0xb95): undefined reference to `SSL_connect'
iot.c:(.text+0xbad): undefined reference to `SSL_get_error'
iot.o: In function `_iot_frame_recv':
iot.c:(.text+0xfe6): undefined reference to `CRYPTO_free'
iot.c:(.text+0x1377): undefined reference to `CRYPTO_free'
iot.o: In function `_iot_do_read':
iot.c:(.text+0x1443): undefined reference to `SSL_read'
iot.c:(.text+0x1458): undefined reference to `SSL_get_error'
iot.c:(.text+0x1489): undefined reference to `SSL_pending'
iot.c:(.text+0x150e): undefined reference to `SSL_read'
iot.c:(.text+0x1564): undefined reference to `CRYPTO_malloc'
iot.c:(.text+0x1595): undefined reference to `SSL_read'
iot.c:(.text+0x15d2): undefined reference to `SSL_read'
iot.c:(.text+0x15e0): undefined reference to `SSL_pending'
iot.c:(.text+0x1640): undefined reference to `BIO_test_flags'
iot.c:(.text+0x165a): undefined reference to `BIO_test_flags'
iot.o: In function `_iot_do_write':
...

当我将以下参数添加到编译器时,我得到一个不同的错误:

michael@michael-VirtualBox:~/$ cc -lssl -lcrypto iot.o tun2iot.o -o tun2iot /usr/lib/i386-linux-gnu/libcrypto.a /usr/lib/i386-linux-gnu/libssl.a 
/usr/lib/i386-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':
(.text+0x1d): undefined reference to `dlopen'
/usr/lib/i386-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':
(.text+0x33): undefined reference to `dlsym'
/usr/lib/i386-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':
(.text+0x3d): undefined reference to `dlclose'
/usr/lib/i386-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_func':
(.text+0x3b1): undefined reference to `dlsym'
/usr/lib/i386-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_func':
(.text+0x490): undefined reference to `dlerror'
/usr/lib/i386-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_var':
(.text+0x511): undefined reference to `dlsym'
/usr/lib/i386-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_var':
(.text+0x5f0): undefined reference to `dlerror'
/usr/lib/i386-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_load':
(.text+0x667): undefined reference to `dlopen'
/usr/lib/i386-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_load':
(.text+0x6de): undefined reference to `dlclose'
/usr/lib/i386-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_load':
(.text+0x715): undefined reference to `dlerror'
/usr/lib/i386-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_pathbyaddr':
(.text+0x7b1): undefined reference to `dladdr'
/usr/lib/i386-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_pathbyaddr':
(.text+0x819): undefined reference to `dlerror'
/usr/lib/i386-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_unload':
(.text+0x87a): undefined reference to `dlclose'
/usr/lib/i386-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_free':
(.text+0x4f): undefined reference to `inflateEnd'
/usr/lib/i386-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_free':
(.text+0x6b): undefined reference to `deflateEnd'
/usr/lib/i386-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_ctrl':
(.text+0x252): undefined reference to `deflate'
/usr/lib/i386-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_ctrl':
...

有人有什么想法吗??

4

1 回答 1

5

cc -lssl -lcrypto iot.o tun2iot.o -o tun2iot

此命令行不正确。参见例如this以获得解释。

于 2013-09-04T02:50:42.160 回答