I've compiled a C++ static library by using CMake as my building tool and I want to link it to my iOS app.
I created a simple 'Empty' application in Xcode and linked my library called libengine.a to it.
I tried to compile my iOS project and the linker gave me this warning:
ignoring file /Users/.../build/engine/libengine.a, file was built for archive which is not the architecture being linked (i386): /Users/.../build/engine/libengine.a
As I understand it, I need to compile my library for ARM processors. The problem is I don't know how.
I think CMake really lacks good tutorials.
Anyways, my CMake scripts are attached below.
Any help would be greatly appreciated.
Thanks, Tal.
Here is my main CMake script:
cmake_minimum_required(VERSION 2.8) project(movie-night) if (DEFINED PLATFORM) include(toolchains/ios.cmake) endif() add_definitions(-Wall) set(DEBUG) if (DEFINED DEBUG) add_definitions(-g) endif() if (DEFINED RELEASE) add_definitions(-O3) endif() add_subdirectory(engine) add_subdirectory(ui) add_subdirectory(test)
Here is my toolchains/ios.cmake file:
set(CMAKE_SYSTEM_NAME Darwin) set(CMAKE_SYSTEM_PROCESSOR arm)
Just use this toolchain file: http://code.google.com/p/ios-cmake/ and use it as
cmake -DCMAKE_TOOLCHAIN_FILE=path_to_your_toolchain_file
Then, in CMakeLists.txt
:
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch armv7") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch armv7")
By following cmake-toolchains documentation I did like below:
cmake -G Xcode -B build \ -DCMAKE_SYSTEM_NAME=iOS \ -DCMAKE_Swift_COMPILER_FORCED=true \ -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0
Note: That assignment CMAKE_OSX_DEPLOYMENT_TARGET=11.0
is not a mistake when targeting iOS.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With