{"id":42729130,"url":"https://github.com/ensody/native-builds","last_synced_at":"2026-02-07T19:20:34.926Z","repository":{"id":304466016,"uuid":"1018871945","full_name":"ensody/native-builds","owner":"ensody","description":"Native builds of popular libraries for Kotlin Multiplatform. Published to Maven Central.","archived":false,"fork":false,"pushed_at":"2026-01-29T18:17:57.000Z","size":201,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-30T04:20:00.565Z","etag":null,"topics":["curl-library","kmp","kotlin-multiplatform","libcurl","liblz4","libz","libzstd","nativebuilds","openssl-library","static-library","zstd-lib"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ensody.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":"NOTICE","maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-07-13T08:26:07.000Z","updated_at":"2026-01-29T18:05:01.000Z","dependencies_parsed_at":null,"dependency_job_id":"8c84cb6e-1193-4121-84cb-f47cb90736e1","html_url":"https://github.com/ensody/native-builds","commit_stats":null,"previous_names":["ensody/native-builds"],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/ensody/native-builds","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ensody%2Fnative-builds","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ensody%2Fnative-builds/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ensody%2Fnative-builds/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ensody%2Fnative-builds/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ensody","download_url":"https://codeload.github.com/ensody/native-builds/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ensody%2Fnative-builds/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29205244,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-07T17:44:10.191Z","status":"ssl_error","status_checked_at":"2026-02-07T17:44:07.936Z","response_time":63,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["curl-library","kmp","kotlin-multiplatform","libcurl","liblz4","libz","libzstd","nativebuilds","openssl-library","static-library","zstd-lib"],"created_at":"2026-01-29T17:08:45.999Z","updated_at":"2026-02-07T19:20:34.898Z","avatar_url":"https://github.com/ensody.png","language":"Kotlin","readme":"# Native builds of C/C++ libraries for Kotlin Multiplatform\n\n[![Maven Central](https://img.shields.io/maven-central/v/com.ensody.nativebuilds/nativebuilds-gradle-plugin?label=nativebuilds-gradle-plugin\u0026color=%2345cf00\u0026filter=!*-*)](https://central.sonatype.com/artifact/com.ensody.nativebuilds/nativebuilds-gradle-plugin)\n\nThis project regularly builds the latest available vcpkg version of the following libraries:\n\n* **OpenSSL** [![Maven Central](https://img.shields.io/maven-central/v/com.ensody.nativebuilds/openssl-headers?label=\u0026color=%2345cf00\u0026filter=!*-*)](https://central.sonatype.com/artifact/com.ensody.nativebuilds/openssl-headers)\n  * `com.ensody.nativebuilds:openssl-headers`: headers\n  * `com.ensody.nativebuilds:openssl-libcrypto`: core crypto library\n  * `com.ensody.nativebuilds:openssl-libssl`: TLS library (optional; depends on libcrypto)\n* **curl** [![Maven Central](https://img.shields.io/maven-central/v/com.ensody.nativebuilds/curl-headers?label=\u0026color=%2345cf00\u0026filter=!*-*)](https://central.sonatype.com/artifact/com.ensody.nativebuilds/curl-headers)\n  * `com.ensody.nativebuilds:curl-headers`: headers\n  * `com.ensody.nativebuilds:curl-libcurl`: static library (depends on openssl, nghttp2, nghttp3, ngtcp2, zlib)\n* **nghttp2** [![Maven Central](https://img.shields.io/maven-central/v/com.ensody.nativebuilds/nghttp2-headers?label=\u0026color=%2345cf00\u0026filter=!*-*)](https://central.sonatype.com/artifact/com.ensody.nativebuilds/nghttp2-headers)\n  * `com.ensody.nativebuilds:nghttp2-headers`: headers\n  * `com.ensody.nativebuilds:nghttp2-libnghttp2`: static library\n* **nghttp3** [![Maven Central](https://img.shields.io/maven-central/v/com.ensody.nativebuilds/nghttp3-headers?label=\u0026color=%2345cf00\u0026filter=!*-*)](https://central.sonatype.com/artifact/com.ensody.nativebuilds/nghttp3-headers)\n  * `com.ensody.nativebuilds:nghttp3-headers`: headers\n  * `com.ensody.nativebuilds:nghttp3-libnghttp3`: static library\n* **ngtcp2** [![Maven Central](https://img.shields.io/maven-central/v/com.ensody.nativebuilds/ngtcp2-headers?label=\u0026color=%2345cf00\u0026filter=!*-*)](https://central.sonatype.com/artifact/com.ensody.nativebuilds/ngtcp2-headers)\n  * `com.ensody.nativebuilds:ngtcp2-headers`: headers\n  * `com.ensody.nativebuilds:ngtcp2-libngtcp2`: main static library\n  * `com.ensody.nativebuilds:ngtcp2-libngtcp2_crypto_ossl`: OpenSSL helper library\n* **brotli** [![Maven Central](https://img.shields.io/maven-central/v/com.ensody.nativebuilds/brotli-headers?label=\u0026color=%2345cf00\u0026filter=!*-*)](https://central.sonatype.com/artifact/com.ensody.nativebuilds/brotli-headers)\n  * `com.ensody.nativebuilds:brotli-headers`: headers\n  * `com.ensody.nativebuilds:brotli-libbrotlicommon`: common static library\n  * `com.ensody.nativebuilds:brotli-libbrotlidec`: decompression static library (depends on libbrotlicommon)\n  * `com.ensody.nativebuilds:brotli-libbrotlienc`: compression static library (depends on libbrotlicommon)\n* **lz4** [![Maven Central](https://img.shields.io/maven-central/v/com.ensody.nativebuilds/lz4-headers?label=\u0026color=%2345cf00\u0026filter=!*-*)](https://central.sonatype.com/artifact/com.ensody.nativebuilds/lz4-headers)\n  * `com.ensody.nativebuilds:lz4-headers`: headers\n  * `com.ensody.nativebuilds:lz4-libzl4`: static library\n* **zlib** [![Maven Central](https://img.shields.io/maven-central/v/com.ensody.nativebuilds/zlib-headers?label=\u0026color=%2345cf00\u0026filter=!*-*)](https://central.sonatype.com/artifact/com.ensody.nativebuilds/zlib-headers)\n  * `com.ensody.nativebuilds:zlib-headers`: headers\n  * `com.ensody.nativebuilds:zlib-libz`: static library\n* **zstd** [![Maven Central](https://img.shields.io/maven-central/v/com.ensody.nativebuilds/zstd-headers?label=\u0026color=%2345cf00\u0026filter=!*-*)](https://central.sonatype.com/artifact/com.ensody.nativebuilds/zstd-headers)\n  * `com.ensody.nativebuilds:zstd-headers`: headers\n  * `com.ensody.nativebuilds:zstd-libzstd`: static library\n\nThe artifacts are published to Maven Central, so they can be easily consumed by Gradle and Kotlin Multiplatform projects.\nA Gradle plugin is also provided to simplify the integration of the header files.\n\nApart from being easier to integrate, this project helps you stay up to date.\nThe NativeBuilds automatically publish new versions to Maven Central.\nTools like Dependabot can notify you of version updates coming from NativeBuilds.\nFor security critical libraries like OpenSSL this automation is very helpful and important.\n\nIf you're a library author:\nThis project also allows consumers of your library to update the underlying native library without you having to publish a new version of your own library.\nEach static library (e.g. OpenSSL) is packaged like any other Kotlin module, so the normal Gradle dependency resolution rules apply.\nIt's even possible to substitute the static library with a debug version.\n\nFinally, this project allows sharing/reusing the same underlying static library (e.g. OpenSSL or libcurl) in different projects.\nFor example, a KMP crypto library could depend on libcrypto.a and Ktor could also depend on libcrypto.a without causing duplication or symbol conflicts.\n\n## Usage\n\n### Prerequisites\n\nIf you want to implement a JNI integration in C/C++ using the NativeBuilds Gradle plugin, you must install [Zig](https://ziglang.org) and place it in your PATH.\nZig is used for cross-compiling your C/C++ code to all targets (linuxArm64, linuxX64, macosArm64, macosX64, mingwX64).\n\nYou don't need Zig if you're just consuming the pre-built libraries (i.e., you're not writing any C/C++ code).\n\n### Example\n\nThe `example` folder in this repo contains a minimal sample project which just calls `ZSTD_versionString()` from libzstd. It builds for several native targets and JVM and Android. You have to run `./gradlew assemble` once to build all necessary artifacts, so the IDE's Gradle sync won't warn about missing files.\n\nTake a look at the [Kompressor](https://github.com/ensody/Kompressor) project to see a slightly more complex real-world example. NativeBuilds is used in the modules that are named \"...--nativelib\".\n\n### Step by step\n\nAdd the dependencies, based on the Maven modules mentioned above, to your `gradle/libs.versions.toml`:\n\n```toml\n[versions]\n# Note: these might not be the latest version numbers. Please check the version badges above.\nopenssl = \"3.6.0.13\"\nnativebuilds = \"0.8.0\"\n\n[libraries]\n# KMP wrapper module for libcrypto.a\nnativebuilds-openssl-libcrypto = { module = \"com.ensody.nativebuilds:openssl-libcrypto\", version.ref = \"openssl\" }\n# KMP wrapper module for libssl.a\nnativebuilds-openssl-libssl = { module = \"com.ensody.nativebuilds:openssl-libssl\", version.ref = \"openssl\" }\n# Needed to integrate the OpenSSL headers for cinterop (only if you're creating a C/C++ wrapper\n# and need to call the C API directly).\nnativebuilds-openssl-headers = { module = \"com.ensody.nativebuilds:openssl-headers\", version.ref = \"openssl\" }\n\n[plugins]\nnativebuilds = { id = \"com.ensody.nativebuilds\", version.ref = \"nativebuilds\" }\n```\n\nAdd the plugin to your `build.gradle.kts`:\n\n```kotlin\nplugins {\n    kotlin(\"multiplatform\")\n    id(\"com.android.kotlin.multiplatform.library\") // or com.android.library\n    alias(libs.plugins.nativebuilds)\n}\n\nkotlin {\n    // List all desired targets. The NativeBuilds Gradle plugin will take the active targets into account.\n    androidTarget()\n    jvm()\n    iosArm64()\n    iosSimulatorArm64()\n    iosx64()\n    tvosArm64()\n    linuxArm64()\n    linuxX64()\n    mingwX64()\n\n    // Add the KMP dependency containing the pre-built static library (the .a file)\n    sourceSets.nativeMain.dependencies {\n        api(libs.nativebuilds.openssl.libcrypto)\n    }\n\n    // If you need direct access to the libcrypto/OpenSSL API you have to activate cinterop\n    // for the OpenSSL header files.\n    cinterops(libs.nativebuilds.openssl.headers) {\n        definitionFile.set(file(\"src/nativeMain/cinterop/openssl.def\"))\n    }\n}\n\n// Add the KMP dependency for JNI C++ integration. This will integrate both Android and JVM.\njniNativeBuild(\n    name = \"libcrypto-jni\",\n    // This links against the libcrypto shared library and makes the headers available in your C/C++ code.\n    nativeBuilds = listOf(\n        libs.nativebuilds.openssl.headers,\n        libs.nativebuilds.openssl.libcrypto,\n    ),\n) {\n    // Path(s) to the JNI C++ source code (where the .cpp files reside)\n    inputFiles.from(\"src/jvmCommonMain/jni\")\n\n    // Optional: Path(s) to any additional headers\n    // includeDirs.from(\"../jni/common/include\")\n}\n\n// This allows Android unit tests to run on the host\nsubstituteAndroidNativeLibsInUnitTests()\n```\n\nFor Kotlin/Native, create `src/nativeMain/cinterop/openssl.def`, but don't define `staticLibraries`.\nThe native .a is already part of `api(libs.nativebuilds.openssl.libcrypto)` in the `dependencies` block above.\n\n```\npackage = my.package.openssl\nheaderFilter = openssl/*\nheaders = openssl/evp.h \\\n          openssl/kdf.h \\\n          openssl/err.h \\\n          openssl/encoder.h \\\n          openssl/decoder.h \\\n          openssl/ec.h\ncompilerOpts = -DOPENSSL_NO_DEPRECATED\n```\n\nMake sure your `gradle.properties` activates cinterop:\n\n```\nkotlin.mpp.enableCInteropCommonization=true\n```\n\nAfter a Gradle sync you can import the OpenSSL APIs within nativeMain (or iosMain etc.).\n\nAlso, you can place JNI C++ code under `src/jvmCommonMain/jni` (as configured above).\nYou don't need to write any additional build scripts (not even the Android CMakeLists.txt).\nOn the JVM and Android, you can load the shared library at runtime like this:\n\n```kotlin\nNativeBuildsJvmLoader.load(NativeBuildsJvmLibCrypto)\n```\n\nAgain, take a look at [Kompressor](https://github.com/ensody/Kompressor) for a real-world usage example.\n\n## Android unit tests\n\nThe NativeBuilds Gradle plugin provides a helper function for Android unit tests which substitutes all Android JNI dependencies with their JVM counterpart. Without that rule, Android unit tests with JNI dependencies would fail because the tests run directly on the host instead of an Android emulator - while the JNI dependencies are usually only built for Android only instead of for the host.\n\nThis substitution helper only changes the Android unit tests. The main Android source-set stays untouched. Add this to your build.gradle.kts or build-logic module:\n\n```kotlin\nsubstituteAndroidNativeLibsInUnitTests()\n```\n\nIf you want to customize the rule, you can use the code in [AndroidSubstitutionRule.kt](https://github.com/ensody/native-builds/blob/main/nativebuilds-gradle-plugin/src/main/kotlin/com/ensody/nativebuilds/AndroidSubstitutionRule.kt) as a starting point.\n\n## Local testing\n\nNote: Only not-yet-published versions get built. In `nativebuilds/build.gradle.kts` you can change the\n`republishVersionSuffix` to re-map to a new version in order to force a new build.\n\n```shell\nexport ANDROID_NDK_ROOT=$ANDROID_SDK_ROOT/ndk/29.0.13599879\nexport BUILD_TARGETS=macosArm64,macosX64,iosArm64,iosSimulatorArm64,iosX64,androidNativeArm64,androidNativeArm32\n./gradlew assembleProjects\nPUBLISHING=true ./gradlew generateBuildScripts\n# This publishes to build/localmaven\nPUBLISHING=true WITH_WRAPPERS=true ./gradlew publishAllPublicationsToLocalMavenRepository\n# Alternatively, you can publish to mavenLocal\n# PUBLISHING=true WITH_WRAPPERS=true ./gradlew pTML\n```\n\n## License\n\n```\nCopyright 2026 Ensody GmbH, Waldemar Kornewald\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n   http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fensody%2Fnative-builds","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fensody%2Fnative-builds","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fensody%2Fnative-builds/lists"}