Open H4kt opened 1 year ago
Initially, I had experienced the same error message when running CMake on macOS Ventura 13.1 (Processor: 2,3 GHz 8-Core Intel Core i9):
$ build % java --version
openjdk 17.0.3 2022-04-19 LTS
OpenJDK Runtime Environment Corretto-17.0.3.6.1 (build 17.0.3+6-LTS)
OpenJDK 64-Bit Server VM Corretto-17.0.3.6.1 (build 17.0.3+6-LTS, mixed mode, sharing)
$ build % cmake ..
-- The CXX compiler identification is AppleClang 14.0.0.14000029
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found JNI: /Users/levente.hunyadi/Library/Java/JavaVirtualMachines/corretto-17.0.3/Contents/Home/include found components: AWT JVM
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/levente.hunyadi/Documents/ktbind/cpp/build
$ build % make
[ 50%] Building CXX object CMakeFiles/ktbind_java.dir/test/java.cpp.o
clang: fatal error: unable to execute command: Segmentation fault: 11
Apple clang version 14.0.0 (clang-1400.0.29.202)
Target: x86_64-apple-darwin22.2.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
make[2]: *** [CMakeFiles/ktbind_java.dir/test/java.cpp.o] Error 254
make[1]: *** [CMakeFiles/ktbind_java.dir/all] Error 2
make: *** [all] Error 2
I had also tried setting the compiler to Clang version 15.0.6 (installed with Homebrew), to no avail. It turns out the culprit is in struct ArgType<T>
:
// returns the corresponding array type for the base type
constexpr static std::string_view array_type_prefix = "[";
constexpr static std::string_view array_type_sig = join_v<array_type_prefix, ArgType<T>::type_sig>;
After these (unused) constant expressions have been removed, the project compiles without error, and unit tests in the Kotlin project succeed.
The changes are pushed to my fork of KtBind. (I am no longer affiliated with Kheiron Medical and don't control this repository.)
Hey there, I'm really curious about this project because it really allows me to get rid of all of the pain when working with JNI
Environment:
OS: macOS 13.0 Processor/Arch: Apple M1 Pro
Use case
I was attempting to build a modified sample from your readme file just to get started
File structure
src/main.cpp
I tried building it using Gradle with
cpp-library
plugin and even tried a manual build using g++ in a command line. Both ways were unsuccessfulApple clang using Gradle
buid.gradle.kts
output
Manual build using g++
build.sh
output