1

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

  1. Download thrift lib from Download Link

  2. After extracting & open terminal on folder

  3. mkdir build-ios && cd build-ios

  4. Run 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
    ..

  5. cmake --build . --target install --config Release (Failed here)

  6. 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

8
  • 1
    Your DemoApp repository is private, and what version of thrift are you trying to build? Also, please show the output of a VERBOSE build so we know what the exact command line is. from the public repo it is clear that libthriftz links against thrift, which does include TProtocol.cpp. Commented Feb 12 at 8:11
  • @Botje I made the repo public Commented Feb 12 at 8:16
  • It only "builds successfully" to a static library because static libraries do not care about missing symbols. Can you build thrift manually with the same settings, compiler and SDK? Commented Feb 12 at 8:30
  • I am not sure what to do you mean by build thrift manually, can you please provide more info what I can try ? Commented Feb 12 at 9:18
  • You wrote a metric ton of CMake code to build thrift automatically. Try doing it yourself first with a simple cmake invocation. Commented Feb 12 at 10:15

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.