编译过程中出现以下错误
[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.*查找下在哪个路径下