I am trying to build a few lib for iOS but I am getting error for thrift lib version 0.21.0
below is the config that I am using to build it
ExternalProject_Add(thrift
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${THRIFT_DIR}
INSTALL_DIR ${THIRDPARTY_INSTALL_DIR}
CMAKE_ARGS ${EXTERNAL_PROJECT_CMAKE_ARGS}
-DOPENSSL_ROOT_DIR=${OPENSSL_INSTALL_DIR}
-DOPENSSL_CRYPTO_LIBRARY=${OPENSSL_INSTALL_DIR}/lib/libcrypto.a
-DOPENSSL_SSL_LIBRARY=${OPENSSL_INSTALL_DIR}/lib/libssl.a
-DBoost_INCLUDE_DIR=${BOOST_INCLUDE_DIR}
-DWITH_ZLIB=${ZLIB_INSTALL_DIR}
-DCMAKE_FIND_LIBRARY_SUFFIXES=".a"
-DBUILD_SHARED_LIBS=ON
-DBUILD_JAVA=OFF
-DBUILD_JAVASCRIPT=OFF
-DBUILD_NODEJS=OFF
-DBUILD_PYTHON=OFF
-DBUILD_PY3=OFF
-DBUILD_QT=OFF
-DBUILD_QT4=OFF
-DBUILD_RUBY=OFF
-DBUILD_PHP=OFF
-DBUILD_SWIFT=OFF
-DBUILD_TESTING=OFF
BUILD_COMMAND make clean && make CFLAGS+=-DOPENSSL_NO_SSL3 CFLAGS+=-fPIC CXXFLAGS+=-DOPENSSL_NO_SSL3 CXXFLAGS+=-fPIC
INSTALL_COMMAND make install
)
I am getting error
[ 93%] Linking CXX shared library ../libthriftz.dylib
cd /Users/Technaharia/Downloads/Demo/build-ios/SDKThirdParty-prefix/src/SDKThirdParty-build/thrift-prefix/src/thrift-build/lib/cpp && /Applications/CMake.app/Contents/bin/cmake -E cmake_link_script CMakeFiles/thriftz.dir/link.txt --verbose=1
Undefined symbols for architecture arm64:
"apache::thrift::GlobalOutput", referenced from:
apache::thrift::transport::TZlibTransport::checkZlibRvNothrow(int, char const*) in TZlibTransport.cpp.o
"apache::thrift::protocol::TProtocol::skip_virt(apache::thrift::protocol::TType)", referenced from:
vtable for apache::thrift::protocol::TProtocolDefaults in THeaderProtocol.cpp.o
"apache::thrift::protocol::TProtocol::~TProtocol()", referenced from:
std::__1::__shared_ptr_emplace<apache::thrift::protocol::TBinaryProtocolT<apache::thrift::transport::THeaderTransport, apache::thrift::protocol::TNetworkBigEndian>, std::__1::allocator<apache::thrift::protocol::TBinaryProtocolT<apache::thrift::transport::THeaderTransport, apache::thrift::protocol::TNetworkBigEndian> > >::~__shared_ptr_emplace() in THeaderProtocol.cpp.o
std::__1::__shared_ptr_emplace<apache::thrift::protocol::TBinaryProtocolT<apache::thrift::transport::THeaderTransport, apache::thrift::protocol::TNetworkBigEndian>, std::__1::allocator<apache::thrift::protocol::TBinaryProtocolT<apache::thrift::transport::THeaderTransport, apache::thrift::protocol::TNetworkBigEndian> > >::~__shared_ptr_emplace() in THeaderProtocol.cpp.o
apache::thrift::protocol::TBinaryProtocolT<apache::thrift::transport::THeaderTransport, apache::thrift::protocol::TNetworkBigEndian>::~TBinaryProtocolT() in THeaderProtocol.cpp.o
But if I -DBUILD_SHARED_LIBS=ON to -DBUILD_SHARED_LIBS=OFF it builds successfully but it creates only .a lib not .dylib that is required for another lib
The problem I think is zlib is not linking with thrift
I also tried to build thrift only using below config
Download thrift lib from Download Link
After extracting & open terminal on folder
mkdir build-ios && cd build-iosRun below command
cmake
-DCMAKE_TOOLCHAIN_FILE=/Users/varun/Downloads/ios-cmake-master/ios.toolchain.cmake
-DPLATFORM=OS64
-DCMAKE_INSTALL_PREFIX=../install-ios
-DOPENSSL_INCLUDE_DIR={Path to openssl include dir}
-DOPENSSL_ROOT_DIR={Path to openssl (built for iOS) root dir}
-DOPENSSL_CRYPTO_LIBRARY={Path to crypto lib(built for iOS)}/libcrypto.1.1.dylib
-DOPENSSL_SSL_LIBRARY={Path to openssl lib (build for iOS)}/libssl.1.1.dylib
-DBoost_INCLUDE_DIR={Path to boost lib(built for iOS)}/include
-DBUILD_SHARED_LIBS=ON
-DWITH_ZLIB=ON
-DWITH_C_GLIB=OFF
-DWITH_CPP=ON
-DWITH_STATIC_LIB=OFF
..cmake --build . --target install --config Release(Failed here)Check build acrh
otool -L install-ios/lib/libthrift.dylib
Full code to build Thrift with boost, openssl & zlib available Thrift-CPP-iOS
Note: If I build for mac using command ./build.sh mac it builds without any issue but if trues to build for iOS ./build.sh ios then it fails
Any help or direction will be appreciated
cmakeinvocation.