简体   繁体   中英

how to link specific version of shared library in g++

I have the following shared libraries: libssl.so, libssl.so.1.1, libcurl.so, libcurl.so.4, libcurl.so.4.4.0, libcrypto.so, libcrypto.so.1.1 .
All of the libraries are in the openssl folder.
My question is, how can I link version 1.1 of libssl? Is it done automatically? I've tried the following:

g++ -c my_file_name.cpp -std=c++11 -w -fpermissive -lpthread --coverage $(INCLUDES) `pkg-config --cflags glib-2.0` `pkg-config --libs glib-2.0` -O0 -Lopenssl -lcrypto -lcurl -lssl
g++ my_file_name.o -o ex -std=c++11 -w -fpermissive -lpthread --coverage -lgtest -lgtest_main -lpthread `pkg-config --cflags glib-2.0` `pkg-config --libs glib-2.0` -O0 -Lopenssl -lcrypto -lcurl -lssl

But it seems that the link doesn't happen. As I still get errors like: error: 'X509_STORE_CTX_get0_chain' was not declared in this scope

Later edit
nm libssl.so.1.1 | grep X509_STORE_CTX_get0_chain nm libssl.so.1.1 | grep X509_STORE_CTX_get0_chain results in 0000000000218210 T X509_STORE_CTX_get0_chain . That would mean that the link that I've done does not happen.
It's worth mentioning that the error comes from a .c file included in the .cpp file.

Probably the libssl.so is a symbolic link to libssl.so.1.1 etc. etc. The problem seems to be related to the missing implementation in one of these library of this function : X509_STORE_CTX_get0_chain . Now you have to check if this symbol is defined in one of these library you link, or if you need to link someone else.

To check this you can execute the following command over each library:

nm libToCheck.so | grep X509_STORE_CTX_get0_chain

if no one have this symbol defined maybe you missing some library to link. If exist, check the scope of the utilizzation of the function, it could not correspond to the scope declared in the library. Check the namespace or similar.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM