modified CMakeLists.txt for static linking of libcurl #1872
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Linking libcurl dynamically in Linux can be done with package manager distributions of curl (i.e.
sudo apt-get install libcurl4-openssl-dev
). Although such packages come with a static library included, using it causes linker failure. Linker errors seem to be releated to pthread, dl, and openssl.Compiling libcurl from source fixes those linker issues. But evidently curl requires the libraries
ssl
andcrypto
to be after itself on the linker command line. Otherwise the linker will error due to undefined references. The currentCMakeLists.txt
files within BitShares do not have the ssl and crypto libraries after curl. This PR fixes that.Additional notes:
The directive
CURL_STATICLIB
is already used for statically linking curl in Windows. I am reusing it in Linux to specify the library to link to and add the ssl and crypto libraries after curl.Calling cmake without
CURL_STATICLIB
will (in all cases I have seen) default to using dynamic libraries, which do not seem to care about where the ssl and crypto libraries are on the linker command line.Linking with curl dynamically results in a witness_node binary with the following output from ldd:
Linking with curl statically results in a witness_node binary with the following output from ldd: