lundi 1 août 2016

Facing issues in building a C++ shared library for multiple architectures (x86_64, armv7, armv7s, arm64, i386)

I'm totally confused and in need of help from someone who has created C++ shared library that will work on any platform using any IDE.

What i have done so far:

1) Created a shared library using cmake in Ubuntu.

2) Transferred source files and Makefile (cmake) to MacOSX (El Capitan)

3) Created the build directory

4) Using Terminal in Mac OS, i ran :

$ cmake ..
$ sudo make install  

5) Created an Xcode iOS Project that support armv7 and arm64 architectures

6) Used header search path and library search path to find the headers and library i had installed in

/usr/local/include/ 

and

/usr/local/lib

7) Used one of the included one of the library header file in main.mm (renamed main.m) and created an object for the class

8) Build the project gives me error because of following reason

ld: warning: ignoring file /usr/local/lib/libMyLibrary.dylib, file was built for x86_64 which is not the architecture being linked (arm64): /usr/local/lib/libMyLibrary.dylib

Here are the contents of my cmake

cmake_minimum_required(VERSION 2.8)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -lsqlite3")

#Adding source files
file(GLOB SOURCES "src/*.cpp")

#Generate the shared library from the sources
add_library(MyLibraryName SHARED ${SOURCES})

target_compile_options(MyLibraryFolder PRIVATE -std=c++11 -lsqlite3)

add_executable(MyLibraryName ${SOURCES})

target_link_libraries(MyLibraryName PRIVATE -lsqlite3)

#Set the location for library installation. Use "sudo make install" to apply
install(TARGETS MyLibraryName DESTINATION /usr/local/lib)

install(DIRECTORY inc/${MyLibraryName_CPP} DESTINATION /usr/local/include)


Can anyone help me with this, Please...

Aucun commentaire:

Enregistrer un commentaire