I am trying to export a function to shared object (.so
) using NDK from c++ using terminal on macOS mojave . I have installed latest versions of command line tool and Xcode.
Here's my GetNumber()
which i want to export
#include <iostream>
#define DllExport __declspec(dllexport)
extern "C" {
DllExport int GetNumber() {
return 5 ;
}
}
After compiling the code using NDK , it throws the following error ,
I tried out clang and Xcode compiler as well as on tried same patterns on Windows and Ubuntu . I get the same error .
You should use JNIEXPORT
instead of DllExport
on Android platforms.
The referenced tutorial you provided in your question is too old for current Android NDK development.