Project homepage Mailing List  Warmcat.com  API Docs  Github Mirror 
{"schema":"libjg2-1", "vpath":"/git/", "avatar":"/git/avatar/", "alang":"", "gen_ut":1713458640, "reponame":"libwebsockets", "desc":"libwebsockets lightweight C networking library", "owner": { "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" },"url":"https://libwebsockets.org/repo/libwebsockets", "f":3, "items": [ {"schema":"libjg2-1", "cid":"762a9ce2d7c48f305cc0c1f278650891", "oid":{ "oid": "f28a45246e7ea479718ddba5e80deb355b23f5f3", "alias": [ "refs/heads/main"]},"blobname": "READMEs/README.build-android.md", "blob": "# Building for Android NDK\n\nIf you have the ndk and prebuilt toolchains with that, you can simply build\nlws library for your android app from one cmake and one make command.\n\nHowever if you want a tls lib, you have to take care of building and pointing\nto that first. But if it's a cmake project like mbedtls, that also is just a\nmatter of one cmake and one make.\n\n## Installing NDK pieces\n\nThere's probably a more direct way but the official way is install the whole\nAndroid Studio and then run `sdkmanager` to install a recent NDK.\n\nI installed the sdk and ndk pieces into /opt/android/ and that's how the\n`./contrib/cross-aarch64-android.cmake` toolchain file is shipped. You can\nadapt some settings at the top of that file including the path if needed.\n\n## Fetching lws (needed first for cross toolchain file)\n\nIt doesn't care where you put these projects, but for simplicity they should\nbe in the same parent dir, like\n\n```\n - /home/someone\n - /home/someone/libwebsockets\n - /home/someone/mbedtls\n```\n\nThe reason is that building mbedtls need the cross toolchain file from\nlibwebsockets, that's also why we have to get libwebsockets first now but\nbuild it later.\n\n```\n$ git clone https://libwebsockets.org/repo/libwebsockets\n```\n\n## Building mbedtls\n\n```\n$ git clone https://github.com/ARMmbed/mbedtls.git\n$ cd mbedtls\n$ mkdir build\n$ cd build\n$ rm -f CMakeCache.txt \u0026\u0026 \u005c\n cmake .. -DCMAKE_TOOLCHAIN_FILE\u003d../libwebsockets/contrib/cross-aarch64-android.cmake \u005c\n -DUSE_SHARED_MBEDTLS_LIBRARY\u003d1 \u005c\n -DENABLE_PROGRAMS\u003d0 \u005c\n -Wno-dev \u0026\u0026 \u005c\n make -j \u0026\u0026 \u005c\n cmake --install .\n```\n\nThe lws toolchain file sets the path to install into as the cross root path, so\ndespite it looks like the destination dir is missing for the install, it will\ngo into, eg `/opt/android/ndk/21.1.6352462/platforms/android-24/arch-arm64/lib/libmbedcrypto.a`\nwhere lws will look for it\n\n## Building lws\n\nYou don't need to explain where mbedtls can be found... lws will build with the\nsame toolchain file that sets the cross root to the same place as mbedtls, it\nwill easily find them there without any further hints.\n\n```\n$ mkdir build\n$ cd build\n$ rm -f CMakeCache.txt \u0026\u0026 \u005c\n cmake .. -DCMAKE_TOOLCHAIN_FILE\u003d../libwebsockets/contrib/cross-aarch64-android.cmake \u005c\n -DLWS_WITH_MBEDTLS\u003d1 \u005c\n -DLWS_WITHOUT_TESTAPPS\u003d1 \u0026\u0026 \u005c\n make \u0026\u0026 \u005c\n cmake --install .\n```\n\nThat's it, both mbedtls and lws library and header files are installed into the\nndk cross root.\n","s":{"c":1713458640,"u": 426}} ],"g": 1574,"chitpc": 0,"ehitpc": 0,"indexed":0 , "ab": 1, "si": 0, "db":0, "di":0, "sat":0, "lfc": "0000"}