A simple proof of concept of Kotlin/Native app with a web server inside (C interop for libmicrohttpd). Libmicrohttpd is linked statically so the output executable file shouldn't require any external dependency. I've discovered more complex example of libmicrohttpd+Kotlin/Native project here.
- MacOS: ✅
- Linux: ✅
- Windows: ✅
- This is a gradle project with wrapper included, so you only need installed JRE for gradle to be able to run tasks
- Download, build and install libmicrohttpd (I've used MinGW64@MSYS2 for Windows build). Instruction is here. I've used only
./configure; make; make install
without any flags or manual configuration.
After installing all requirements:
- Open src/nativeInterop/libmicrohttpd.def
- Look through your /usr and /opt dirs (or MSYS2 paths for Windows) for libmicrohttpd installation artifacts, make sure:
- Path to folder containing microhttpd.h is specified at
compilerOpts
- Path to folder containing libmicrohttpd.a is specified at
libraryPaths
- Path to folder containing microhttpd.h is specified at
./gradlew linkReleaseExecutableNative
After building run ./build/bin/native/releaseExecutable/kotlin-native-web-server.kexe
(or whatever executable file is inside). Output:
Server is listening port 8888
Press enter to stop
Open link http://localhost:8888/any-url in browser: