Include self-contained static libcurl

From recent experience, the developer has to be careful about including libcurl as it has many dependencies. Accordingly, I built it into my app so all dependencies are included in the final build.

$ brew install curl-openssl

$ brew remove curl

$ ./configure –disable-shared –enable-static –prefix=/usr/local/lib/curl –disable-shared –enable-static –disable-ldap –disable-sspi –without-librtmp –disable-ftp –disable-file –disable-dict –disable-telnet –disable-tftp –disable-rtsp –disable-pop3 –disable-imap –disable-smtp –disable-gopher –disable-smb –without-libidn –with-openssl=/usr/local/Cellar/openssl@1.1/1.1.1k

$ curl-config –static-libs

Add CURL_STATICLIB in the Preprocessor Definitions of your C++ project. Add all the libs listed by –static-libs with the correct path into your project.

In Windows, use vcpkg to install the static versions and add CURL_STATICLIB to preprocessor defines.

References –

https://curl.se/docs/libs.html

https://forums.macrumors.com/threads/linking-libcurl-statically-on-xcode-8-2.2025806/

https://curl.se/docs/install.html

https://stackoverflow.com/questions/58918128/compile-a-c-at-project-with-libcurl-library-on-macos

https://github.com/curl/curl/issues/585

Anmol

Software Engineer, Dancer and Filmmaker. Currently rebooting his life.

Leave a Reply