undefined reference to `SSL_library_init'错误 - 小众知识

undefined reference to `SSL_library_init'错误

2022-08-14 15:40:41 苏内容
  标签:
阅读:4531

编译过程中出现以下错误

[root@localhost apps]#g++ -o clientclient.o

client.o: In function `main':

client.cpp:(.text+0x15): undefinedreference to `SSL_library_init'

client.cpp:(.text+0x1a): undefinedreference to `TLSv1_client_method'

client.cpp:(.text+0x22): undefinedreference to `SSL_load_error_strings'

client.cpp:(.text+0x2d): undefinedreference to `SSL_CTX_new'

client.cpp:(.text+0x5d): undefinedreference to `SSL_CTX_set_verify'

client.cpp:(.text+0x13e): undefinedreference to `SSL_new'

client.cpp:(.text+0x165): undefinedreference to `SSL_set_fd'

client.cpp:(.text+0x170): undefinedreference to `SSL_connect'

client.cpp:(.text+0x186): undefinedreference to `ERR_print_errors_fp'

client.cpp:(.text+0x19d): undefinedreference to `SSL_get_current_cipher'

client.cpp:(.text+0x1a5): undefinedreference to `SSL_CIPHER_get_name'

client.cpp:(.text+0x1dc): undefinedreference to `SSL_write'

client.cpp:(.text+0x1f2): undefinedreference to `ERR_print_errors_fp'

client.cpp:(.text+0x21b): undefinedreference to `SSL_read'

client.cpp:(.text+0x231): undefinedreference to `ERR_print_errors_fp'

client.cpp:(.text+0x270): undefinedreference to `SSL_shutdown'

client.cpp:(.text+0x28e): undefinedreference to `SSL_free'

client.cpp:(.text+0x299): undefinedreference to `SSL_CTX_fre

解决方法找不到相应的库

gcc -Wall  client.c -lssl -lcrypto -o client

其中-l是指加入的某个库的意思,-lssl 表示加入的库是libssl.so或者是libssl.a的意思,其中lib和扩展名可以不写

至于搜索路径可以-L/lib -L/usr/lib  其中-L/path是搜索路径的意思,可以用find / -name libssl.*查找下在哪个路径下



/home/ec2-user/src/libevent-2.0.22-stable/sample/le-proxy.c:256: undefined reference to `SSL_library_init'

/home/ec2-user/src/libevent-2.0.22-stable/sample/le-proxy.c:257: undefined reference to `ERR_load_crypto_strings'

/home/ec2-user/src/libevent-2.0.22-stable/sample/le-proxy.c:258: undefined reference to `SSL_load_error_strings'

/home/ec2-user/src/libevent-2.0.22-stable/sample/le-proxy.c:259: undefined reference to `OPENSSL_add_all_algorithms_noconf'

/home/ec2-user/src/libevent-2.0.22-stable/sample/le-proxy.c:265: undefined reference to `SSLv23_method'


扩展阅读
相关阅读
© CopyRight 2010-2021, PREDREAM.ORG, Inc.All Rights Reserved. 京ICP备13045924号-1