Building libcurl with static linking to openssl

依然范特西╮ 提交于 2021-01-01 07:32:21

问题


I am trying to build libcurl with static linking to openssl. So to achieve that, I have used following configuration:

OpenSSL:

LDFLAGS="-static”
LIBS="-ldl”

cURL:

LDFLAGS="-static”
CPPFLAGS="-I$(CURDIR)/$(3RDPARTY_DIR)$(OPENSSL)/include   
LDFLAGS="-L$(CURDIR)/$(3RDPARTY_DIR)$(OPENSSL)"
./configure --disable-shared --without-zlib --without-libidn --without-librtmp --disable-ldap —-with-ssl=<path where my openssl is installed>

With this, I am to generate libcurl.a and link it to my code where I am successfully able to handle HTTPS connections, as per my need.

But for the sake of learning purpose, I wanted to know are SSL symbols actually integrated into libcurl or not. So for that, I tried using nm command:

nm -A libcurl.a | grep “SSL_"

But it shows all SSL symbols as Undefined. For example,

U SSL_connect
U SSL_ctrl

So does it mean that symbols from libssl.a and libcrypto.a are NOT actually integrated into libcurl?

If yes, what can be done to actually integrate them into libcurl.a?

Any help is appreciated to help me understand this.


回答1:


Yes, it means that the OpenSSL symbols are not integrated into libcurl.

When you build a static version of libcurl, you get a libcurl.a file suitable for static linking. But you then need to also provide all the (static) dependency libraries as well on the linker command line, you don't normally link them all together into a single static lib first. (If you want that done, you will have to do it yourself; the curl build system won't do it.)

When you want to link your application with a static libcurl built to use a static OpenSSL, you link your application and provide all the necessary libs on the linker command line. On a *nix that means -lcurl -lcrypto -lssl...

(Most libcurl builds will also use additional dependencies).



来源:https://stackoverflow.com/questions/59064582/building-libcurl-with-static-linking-to-openssl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!