libcpr / cpr

C++ Requests: Curl for People, a spiritual port of Python Requests.
https://docs.libcpr.org/
Other
6.49k stars 924 forks source link

iOS 11 - 14 symbol not found issues #906

Closed squidgeface closed 1 year ago

squidgeface commented 1 year ago

Description

We have used VCPKG to add CPR to an xcode project using CMake. We use the framework file in a Unity project to do http requests natively.

CMakeLists.txt (only relevant info):

set_target_properties(${FP_LIBRARY} PROPERTIES
        FRAMEWORK TRUE
        MACOSX_FRAMEWORK_INFO_PLIST "${CMAKE_SOURCE_DIR}/Platforms/iOS/Info.plist"
        XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET "11.0"
        XCODE_ATTRIBUTE_SDKROOT "iphoneos"
        XCODE_ATTRIBUTE_MTL_FAST_MATH YES
        XCODE_ATTRIBUTE_MTL_ENABLE_DEBUG_INFO "INCLUDE_SOURCE"
        XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++"
        XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++11"
        XCODE_ATTRIBUTE_GCC_INLINES_ARE_PRIVATE_EXTERN YES
    )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -Wno-return-type-c-linkage -Wno-unneeded-internal-declaration")

find_package(cpr CONFIG REQUIRED)
target_link_libraries(${FP_LIBRARY} PRIVATE cpr::cpr)

The Xcode project spits out a .framework file which we use successfully on iOS 16

However, it crashes before the app loads on the devices with iOS versions 11-14 with the following error:

dyld: Symbol not found: __ZTTNSt3__119basic_istringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEEE
Referenced from: <path to our framework>
Expected in: /usr/lib/libc++.1.dylib

I've tried lowering the CPR, CURL and OPENSSL versions to see if maybe at some point older iOS versions stopped being supported but haven't had any luck with that.

Just to reiterate - the build works just fine on newer iOS version (tested on iOS16)

Example/How to Reproduce

  1. Create a CPR c++ implementation of an HTTP request
  2. Build an xcode project with the source using the above cmake properties
  3. export the framework
  4. include the framework in a project and call into the framework
  5. build and run the project on an iphone device with iOS 11 to 14

Possible Fix

No response

Where did you get it from?

vcpkg

Additional Context/Your Environment

Building on a mac mini with Apple M1 chip

COM8 commented 1 year ago

First of all, thank you @squidgeface for reporting this. Sadly this seams to be a vcpkg issue, not a cpr issue.

To me this error looks like a miss match in libstdcpp used. If I would guess, this is caused by the change for std::basic_string in cpp17 inside the standard lib. (https://isocpp.org/files/papers/p0636r0.html)

Since we have so many issues with people trying to use vcpkg and failing I discourage you from using it.

I suggest you try using fetch_content directly for cpr. Here is an example: https://github.com/libcpr/example-cmake-fetch-content

Please head over to the vcpkg issue tracker and report this issue there.