CMake Link Executable to shared library (Android Studio 2.2)
<p>I created a small Test Project in the new Version of Android Studio to test the new c++ support. </p>

<p>I try to call a Function from a shared library. The Function is in an other .cpp File</p>

<p>Here is a Part of my CmakeLists.txt File:</p>

<pre><code>add_library(JNI SHARED src/main/cpp/native-lib.cpp)
add_executable(testex src/main/cpp/test2.cpp)
INCLUDE_DIRECTORIES (src/main/cpp)
target_link_libraries(testex JNI)
</code></pre>

<p>The test2.h File:</p>

<pre><code>class Test{
public:
      int side;
      intgetArea();
};
</code></pre>

<p>The test2.cpp File:</p>

<pre><code>#include "test2.h"
int Test::getArea(){
          return side*side;
}
</code></pre>

<p>And a Part of my native-lib.cpp File:</p>

<pre><code>JNIEXPORT jstring JNICALL
.....(JNIEnv *env,jobject instance){
Test *test = new Test();
test-&gt;getArea();
 .
 .
 .
</code></pre>

<p>I get these Error: error:
undefined reference to 'Test::getArea()</p>

<p>clang++: error: linker command failed with exit code 1 (use -v to see invocation)</p>

<p>ninja: build stopped: subcommand failed.</p>

<p>I hope someone can help me :)</p>