-
Notifications
You must be signed in to change notification settings - Fork 612
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CMake configuration is wrong on iOS #451
Comments
Can you explain the error you are receiving? Both set CARES_USE_LIBRESOLV within ares_config.h. And for cmake, it generates the c-ares-config.cmake file containing all the build instructions for any external project linking which should include the libresolv dep. Likewise, for autotools, it generates a package config file that does the same purpose. MacOS actually uses the exact same logic as iOS, I haven't tried the ios toolchain file. We used to autobuild for ios when travis was working, but since they stopped supporting open source, it wasn't re-added for cirrus-ci, its still on the todo list so we may not have visibility into any issues there. That said, in my day job, we use c-ares and build ios apps and I don't recall any issues... |
First of all, there are no errors during the build. But name resolving does not work on iOS devices. We use C-Ares with Curl and get the following error in runtime
Let me show step by step.
I see the following log in console
CARES_USE_LIBRESOLV is undefined as well
Why does it happen? CARES_FUNCTION_IN_LIBRARY (res_servicename resolv HAVE_RES_SERVICENAME_IN_LIBRESOLV)
IF (HAVE_RES_SERVICENAME_IN_LIBRESOLV)
SET (HAVE_LIBRESOLV 1) let's look closer to the CARES_FUNCTION_IN_LIBRARY macro MACRO (CARES_FUNCTION_IN_LIBRARY func lib var)
CHECK_FUNCTION_EXISTS ("${func}" "_CARES_FUNC_IN_LIB_GLOBAL_${func}")
IF ("${_CARES_FUNC_IN_LIB_GLOBAL_${func}}")
→ # in case of iOS we come here!
→ # it because libresolv is a system library on iOS I guess.
→ # as a result, nobody defines HAVE_LIBRESOLV
→ SET (${var} FALSE)
ELSE ()
CHECK_LIBRARY_EXISTS ("${lib}" "${func}" "" ${var})
ENDIF ()
ENDMACRO () PS: there is a piece of magic that I can't explain. The library without libresolv does work on iOS Simulator. But it doesn't on iOS devices |
My guess is something on your system is causing CMAKE_REQUIRED_LIBRARIES to include libresolv already. I haven't looked at that toolchain to see what it does, but I've never used it. In theory libresolv should NOT be in CMAKE_REQUIRED_LIBRARIES ... I'm attempting to add the build to cirrus-ci autobuilds to see what it does there, but I'm not using that toolchain file. |
https://cirrus-ci.com/task/5130141339746304
This is different behavior than what you described. Looks proper to me. |
1、set ENABLE_STRICT_TRY_COMPILE_INT=ON for leetal‘s ios.toolchain.cmake to make sure CMAKE_TRY_COMPILE_TARGET_TYPE is not changed to STATIC_LIBRARY. |
DNS resolving on iOS does not work without libresolv. But identifying dependency with Autotools and CMake are different.
Autotools checks that the function exists in resolv library
CMake, if I understand correctly, checks if the function exists in the system scope and if so, it rejects the library.
Therefore we have
But HAVE_LIBRESOLV is undefined
How to reproduce
Get the iOS toolchain file here and run
The text was updated successfully, but these errors were encountered: