Skip to content

Creating static libraries for a multi platform project #546

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Sokkero opened this issue Apr 9, 2025 · 5 comments · May be fixed by #549
Open

Creating static libraries for a multi platform project #546

Sokkero opened this issue Apr 9, 2025 · 5 comments · May be fixed by #549

Comments

@Sokkero
Copy link

Sokkero commented Apr 9, 2025

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.

@bsergean
Copy link
Collaborator

bsergean commented Apr 9, 2025

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.

@Sokkero
Copy link
Author

Sokkero commented Apr 10, 2025

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

@Sokkero
Copy link
Author

Sokkero commented Apr 10, 2025

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

@Sokkero
Copy link
Author

Sokkero commented Apr 11, 2025

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?

@bsergean
Copy link
Collaborator

ChatGPT recommends this, to compile the library with this option

-D_FORTIFY_SOURCE=0

@Sokkero Sokkero linked a pull request Apr 22, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants