Skip to content

Creating static libraries for a multi platform project #546

Closed

Description

@Sokkero

Hello,
we are developing a mobile game and would like to switch to IXWebSocket for handling socket connections. For this we would need static libraries for the android (armeabi-v7a, arm64-v8a & x86), iOS and mac. We are struggling a bit to compile all these from the project and wondered if we could get some assistance for this case.
The project states it is compatible with android, iOS and mac so would it be possible to get some more detailed instructions for building the project for these platforms? What where the commands/arguments used for compiling libs for these projects by you, the developers?
If all works out I would also be willing to post a PR which includes updates to the README pages for anyone who tries to do the same in the future.

Activity

  1. bsergean commented on Apr 9, 2025

    @bsergean
    Collaborator

    We definitely used a static build of this for android on multiple architectures, but we did use cmake at the time + gradle to drive this.

  2. Sokkero commented on Apr 10, 2025

    @Sokkero
    ContributorAuthor

    So far I have been able to build a static lib for the mac target. For android I am using a customised version of the build_android.sh script.

    ${CMAKE} \
        [path]/IXWebSocket/ \
        -DANDROID_NATIVE_API_LEVEL=23 \
        -DANDROID_ABI=armeabi-v7a \
        -DANDROID_TOOLCHAIN=clang \
        -DANDROID_NDK=${ANDROID_NDK} \
        -G'Unix Makefiles' \
        -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} \
        -DCMAKE_MAKE_PROGRAM=make \
        -DOPENSSL_ROOT_DIR=/opt/homebrew/bin/openSSL \
        -DOPENSSL_LIBRARIES=/opt/homebrew/bin/openSSL/lib \
        -DUSE_TLS=1 \
        -DUSE_OPEN_SSL=1
    

    But this results in:

    -- TLS configured to use openssl
    CMake Error at /Applications/CMake.app/Contents/share/cmake-3.26/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
      Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the
      system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY
      OPENSSL_INCLUDE_DIR)
    Call Stack (most recent call first):
      /Applications/CMake.app/Contents/share/cmake-3.26/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
      /Applications/CMake.app/Contents/share/cmake-3.26/Modules/FindOpenSSL.cmake:670 (find_package_handle_standard_args)
      CMakeLists.txt:209 (find_package)
    

    Any idea how to fix this?
    Also I have yet to try building for iOS. As Ive never done this, I would also be grateful for help/pointers there.
    Thank you in advance

  3. Sokkero commented on Apr 10, 2025

    @Sokkero
    ContributorAuthor

    I found the thread #175 and it seems to have worked using

    ${CMAKE} \
        [path]/IXWebSocket/ \
        -DANDROID_NATIVE_API_LEVEL=23 \
        -DANDROID_ABI=armeabi-v7a \
        -DANDROID_TOOLCHAIN=clang \
        -DANDROID_NDK=${ANDROID_NDK} \
        -G'Unix Makefiles' \
        -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} \
        -DCMAKE_MAKE_PROGRAM=make \
        -DOPENSSL_FOUND=1 \
        -DOPENSSL_INCLUDE_DIR=/opt/homebrew/Cellar/openssl@3/3.4.1/include \
        -DOPENSSL_LIBRARIES="/opt/homebrew/Cellar/openssl@3/3.4.1/lib/libssl.a;/opt/homebrew/Cellar/openssl@3/3.4.1/lib/libcrypto.a" \
        -DUSE_TLS=1 \
        -DUSE_OPEN_SSL=1
    

    Now just iOS is missing

  4. Sokkero commented on Apr 11, 2025

    @Sokkero
    ContributorAuthor

    Linking the android libraries seems to be clashing with our android NDK, resulting in the error android-ndk/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/bits/fortify/poll.h:59: undefined reference to '__poll_chk'.
    Is this simply an error indicating that our android NDK is outdated or would you know more about this?

  5. bsergean commented on Apr 13, 2025

    @bsergean
    Collaborator

    ChatGPT recommends this, to compile the library with this option

    -D_FORTIFY_SOURCE=0
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions