'JNI C++ undefined reference to
i have the following JNI bridge, the bridge compiles and JNI is known to be working but when compiling the C++ code i get errors. Not sure what to do. Android Studio Doesn't mark anything wrong with the code.
extern "C" {
class Singleton {
private:
Singleton();
public:
static Singleton &instance() {
static Singleton INSTANCE;
return INSTANCE;
}
std::string something = "123";
void setSomething(std::string some) {
this->something = std::move(some);
}
std::string getSomething() {
return this->something;
}
};
JNIEXPORT void JNICALL
Java_com_example_jni_JniGcode_init(JNIEnv *env, jobject jniGcode, jstring file_path) {
Singleton::instance().getSomething();
Singleton::instance().setSomething("blabla");
}
JNIEXPORT void JNICALL
Java_com_example_jni_JniGcode_something(JNIEnv *env, jobject thiz) {
Singleton::instance().getSomething();
}
}
the error that im getting:
In function `Singleton::instance()':
/{redacted}/file.cpp:34: undefined reference to `Singleton::Singleton()'
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
