Hello everyone I want to call C++ code from my Kot...
# multiplatform
s
Hello everyone I want to call C++ code from my Kotlin/Native (iOS) code. I have an iOS app which uses a KMP module which needs to call some C++ code. I have written a C wrapper for my C++ code so that C++ in only present in the implementation files (cpp / mm) When I try to do cinterop with something like
Copy code
language = C++
headers=/Users/ovd/IdeaProjects/Mehmaan/reaktor/cpp/Reaktor.h
compilerOpts=-x c++ -std=c++20
linkerOpts=-lstdc++
It fails with the response
error: no member named 'nullptr_t' in the global namespace
I am able to build and run the iOS app using xcode, but I am unable to interface with the C++ code. Sorry if this is a noob question, but I was unable to work around this
I managed to get it running by adding
Copy code
val reaktor by creating {
                defFile(file("$cppRoot/reaktor.def"))
                headers("$cppRoot/Reaktor.h")
                extraOpts("-Xsource-compiler-option", "-std=c++20")
                extraOpts("-Xcompile-source", "$cppRoot/Reaktor.cpp")
            }
In the build.gradle file. Now my C++ code shows up in the IDE, but when I build my iOS app It gives an undefined error for the same function