GithubHelp home page GithubHelp logo

libevent for iOS about libevent HOT 8 CLOSED

palfonsoilluscio avatar palfonsoilluscio commented on September 24, 2024
libevent for iOS

from libevent.

Comments (8)

Coeur avatar Coeur commented on September 24, 2024 1

I was able to build it for iOS and visionOS easily.

  1. Make for Xcode without OpenSSL: cmake -B build -G Xcode -DEVENT__DISABLE_OPENSSL=ON
  2. Open the resulting xcodeproj: open build/libevent.xcodeproj
  3. Change Project's SDKROOT to iOS or visionOS
  4. Build the "event_static" scheme for "Any iOS Device" or "Any visionOS Device"

from libevent.

widgetii avatar widgetii commented on September 24, 2024

Hi, what's the difference between iOS and other platforms static libraries?

from libevent.

palfonsoilluscio avatar palfonsoilluscio commented on September 24, 2024

iOS and macOS for instance, have different SDK versions, which may result in differences in available APIs and features. But in general, while iOS and macOS static libraries share many similarities, differences in architecture, SDK versions, deployment targets, and app distribution requirements may need some adjustments when developing and using static libraries for each platform.

We can probably implement this for at least iOS by using:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -target arm64-apple-ios17.4 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.4.sdk -fembed-bitcode-marker -c -I /path/to/headers src/file_to_compile.c -o output_dir/compiled_file.o

But, if you have a better way to do so, happy to implement it...

Thanks in advance.

from libevent.

palfonsoilluscio avatar palfonsoilluscio commented on September 24, 2024

This is the initial error we are having, before doing anything:

ld: building for 'iOS', but linking in object file (/Users/xxx/Documents/Workspace/xxx/xxx/Frameworks/libevent.a[8](event.o)) built for 'macOS'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

from libevent.

palfonsoilluscio avatar palfonsoilluscio commented on September 24, 2024

If you have maybe a CI script that we can check and help us to build for iOS, that would be great...

Thanks in advance.

from libevent.

azat avatar azat commented on September 24, 2024

ld: building for 'iOS', but linking in object file (/Users/xxx/Documents/Workspace/xxx/xxx/Frameworks/libevent.a8) built for 'macOS'

Looks like some issue in your cross compilation

If you have maybe a CI script that we can check and help us to build for iOS, that would be great...

We only have CI for MacOS -

macos-cmake-job:
runs-on: ${{ matrix.os }}
if: "!contains(github.event.head_commit.message, 'ci/macos skip') && !contains(github.event.head_commit.message, 'ci/macos/cmake skip')"
strategy:
fail-fast: false
matrix:
os: [macos-latest]
EVENT_MATRIX:
- NONE
- NO_SSL
- DISABLE_OPENSSL
- DISABLE_THREAD_SUPPORT
- DISABLE_DEBUG_MODE
- DISABLE_MM_REPLACEMENT
- TEST_EXPORT_STATIC
- TEST_EXPORT_SHARED
steps:
- uses: actions/checkout@v3
- name: Cache Build
uses: actions/cache@v4
with:
path: build
key: ${{ matrix.os }}-cmake-${{ matrix.EVENT_MATRIX }}-v3
- name: Install Depends
run: brew install mbedtls@2
- name: Build
shell: bash
run: |
# NOTE: cmake does not support autodetection of OPENSSL_ROOT_DIR via brew
export OPENSSL_ROOT_DIR=/usr/local/opt/openssl
if [ "${{ matrix.EVENT_MATRIX }}" == "DISABLE_OPENSSL" ]; then
EVENT_CMAKE_OPTIONS="-DEVENT__DISABLE_OPENSSL=ON"
elif [ "${{ matrix.EVENT_MATRIX }}" == "NO_SSL" ]; then
EVENT_CMAKE_OPTIONS="-DEVENT__DISABLE_OPENSSL=ON -DEVENT__DISABLE_MBEDTLS=ON"
elif [ "${{ matrix.EVENT_MATRIX }}" == "DISABLE_THREAD_SUPPORT" ]; then
EVENT_CMAKE_OPTIONS="-DEVENT__DISABLE_THREAD_SUPPORT=ON"
elif [ "${{ matrix.EVENT_MATRIX }}" == "DISABLE_DEBUG_MODE" ]; then
EVENT_CMAKE_OPTIONS="-DEVENT__DISABLE_DEBUG_MODE=ON"
elif [ "${{ matrix.EVENT_MATRIX }}" == "DISABLE_MM_REPLACEMENT" ]; then
EVENT_CMAKE_OPTIONS="-DEVENT__DISABLE_MM_REPLACEMENT=ON"
elif [ "${{ matrix.EVENT_MATRIX }}" == "TEST_EXPORT_STATIC" ]; then
EVENT_CMAKE_OPTIONS="-DEVENT__LIBRARY_TYPE=STATIC -DEVENT__DISABLE_TESTS=ON -DEVENT__DISABLE_SAMPLES=ON"
elif [ "${{ matrix.EVENT_MATRIX }}" == "TEST_EXPORT_SHARED" ]; then
EVENT_CMAKE_OPTIONS="-DEVENT__LIBRARY_TYPE=SHARED -DEVENT__DISABLE_TESTS=ON -DEVENT__DISABLE_SAMPLES=ON"
else
EVENT_CMAKE_OPTIONS=""
fi
EVENT_CMAKE_OPTIONS="$EVENT_CMAKE_OPTIONS -DMBEDTLS_ROOT_DIR=/usr/local/opt/mbedtls@2"
mkdir -p build
cd build
echo [cmake]: cmake .. $EVENT_CMAKE_OPTIONS
cmake .. $EVENT_CMAKE_OPTIONS || (rm -rf * && cmake .. $EVENT_CMAKE_OPTIONS)
cmake --build .
- name: Test
uses: nick-fields/retry@v3
with:
max_attempts: 5
timeout_minutes: 60
shell: bash
command: |
JOBS=1
export CTEST_PARALLEL_LEVEL=$JOBS
export CTEST_OUTPUT_ON_FAILURE=1
cd build
if [ "${{ matrix.EVENT_MATRIX }}" == "TEST_EXPORT_STATIC" ]; then
sudo python3 ../test-export/test-export.py static
elif [ "${{ matrix.EVENT_MATRIX }}" == "TEST_EXPORT_SHARED" ]; then
sudo python3 ../test-export/test-export.py shared
else
cmake --build . --target verify
fi
- uses: actions/upload-artifact@v1
if: failure()
with:
name: ${{ matrix.os }}-cmake-${{ matrix.EVENT_MATRIX }}-build
path: build

from libevent.

pedroalfonsoo avatar pedroalfonsoo commented on September 24, 2024

Looks like some issue in your cross compilation ----> Correct, that's exactly what is happening because we are not able to get a libevent build for iOS.

We hoped we could get that from your team, is that possible or we just need look for another options?

Sorry just trying to understand the next steps.

from libevent.

Coeur avatar Coeur commented on September 24, 2024

Oh, even simpler:

For iOS

cmake -B build -G Xcode -D CMAKE_OSX_SYSROOT=iphoneos
cmake --build build -t event_static

For visionOS

cmake -B build -G Xcode -D CMAKE_OSX_SYSROOT=xros
cmake --build build -t event_static

That's all. No need to disable openssl explicitly, no need to open Xcode : all is automatic and from command-line. Product will be in built in build/lib/Debug/libevent.a.

from libevent.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.