using curl on iOS, I am unable to link with multiple architectures, CurlchkszEQ macro failing using curl on iOS, I am unable to link with multiple architectures, CurlchkszEQ macro failing curl curl

using curl on iOS, I am unable to link with multiple architectures, CurlchkszEQ macro failing


I have chosen to only build for armv7 and armv7s, and still i get this error.

Have you looked at the Xcode build logs to confirm that only -arch armv7 and -arch armv7s are used for compilation?

Your problem is certainly related to the fact that you use a single set of headers (e.g generated for a 32-bit build of the library) even though you try to build a fat executable that combines armv7/v7s and arm64 architectures.

I think you should refer to Nick Zitzmann libcurl pre-built. As you can see the curlbuild.h header that ships with it includes ad-hoc macros to distinguish between ILP32 and LP64:

/* The size of `long', as computed by sizeof. */#ifdef __LP64__#define CURL_SIZEOF_LONG 8#else#define CURL_SIZEOF_LONG 4#endif

Note that the instructions on Nick's page do not include any precision about how this header has been generated - I would say it has been modified specifically to be cross-platform compliant.

UPDATE

The above link is down (one can find a snapshot on the Internet Archive - the latest pre-built was made for libcurl 7.40.0 from 2015-01-08). I made a copy (verbatim) of build-libcurl-ios.sh and curlbuild.h (the single, convenient header made for the iOScURL application) here.

After the armv7 build the build-libcurl-ios.sh makes a copy of the generated 32-bit header:

cp include/curl/curlbuild.h ~/Desktop/curlbuild32.h

Same thing after the arm64 build:

cp include/curl/curlbuild.h ~/Desktop/curlbuild64.h

The final curlbuild.h is no more than a convenient version that includes both 32-bit and 64-bit specifics thanks to #ifdef __LP64__ /* ... */ #else /* ... */ #endif sections. In particular there is more than only CURL_SIZEOF_LONG differences, e.g.:

#define CURL_TYPEOF_CURL_OFF_T int64_t /* 64-bit */#define CURL_TYPEOF_CURL_OFF_T long    /* 32-bit */


I didn't want to go through each of the differences between the 32-bit and 64-bit headers, so instead did this:

  1. Made 32 and 64-bit builds of libcurl including headers, using the script found here: http://feedback.datalogics.com/knowledgebase/articles/821196-building-openssl-and-curl-for-ios-64-bit-platform
  2. Put the headers into include-32 and include-64 directories.
  3. Set header search-paths to include a directory above the directories created in step 2.
  4. Created a header file called my_curl.h like so:

    #ifdef __LP64__#include <include-64/curl/curl.h>#else#include <include-32/curl/curl.h>#endif

Perhaps not the most elegant solution, but it saved me the time (and risk of mistakes) of doing it by hand.