I am trying to compile curl and statically link it to another project. I did manage to compile it for my mac architecture(x86_64) and got "libcurl.a". Now when I try to build:
#include <curl/curl.h>
int main()
{
CURL *curl = curl_easy_init();
}
with g++ tornado.cc -o tornado (path-to-where-it-is)libcurl.a -std=c++11
I get:
Undefined symbols for architecture x86_64:
"_CFArrayAppendValue", referenced from:
_append_cert_to_array in libcurl.a(libcurl_la-darwinssl.o)
"_CFArrayCreate", referenced from:
_darwinssl_connect_common in libcurl.a(libcurl_la-darwinssl.o)
"_CFArrayCreateMutable", referenced from:
_darwinssl_connect_step2 in libcurl.a(libcurl_la-darwinssl.o)
"_CFArrayGetCount", referenced from:
_darwinssl_connect_common in libcurl.a(libcurl_la-darwinssl.o)
"_CFArrayGetValueAtIndex", referenced from:
_darwinssl_connect_common in libcurl.a(libcurl_la-darwinssl.o)
"_CFDataCreate", referenced from:
_append_cert_to_array in libcurl.a(libcurl_la-darwinssl.o)
As I understand it wants to get links for darwinssl, but I do not know where to get those.
The readme for curl (https://github.com/biasedbit/curl-ios-build-scripts/blob/master/README.md) - does mention it depends on libz.dylib and Security.framework but does not give any clues about what they are, when and how do I need them, and how to include those.
P.S. the regular curl inclusion works fine: g++ tornado.cc -o tornado -lcurl -std=c++11
I found some time to mess around on the mac. Here's the command that worked for me:
gcc main.cpp -I path/to/include path/to/libcurl.a -framework Foundation -lz -framework Security
Basically, you need -framework Foundation
, -lz
and -framework Security
.