Link library with android ndk app in visual studio 2015

I created the Native-Activity app for Android in Visual Studio 2015. If I just ran the sample code, the application works. However, I want to use an external library in my application. To do this, I do the following:

  • Add include directory in C / C ++ → General → Additional Include Directories
  • Add the lib / x86 path to Linker-> General-> Additional Library Directories
  • Add Library Name in Linker-> Input-> Library Dependencies

With these settings, I can use some library code in my project and compile it. If, for example, I have to omit the library directory, the compiler complains about unrealized functions.

But if I run the generated apk on an emulator or Android phone, it will instantly work, even before it breaks the point.

Even when I don't actually use the library (comment out all my own code), but just link it, the application will crash.

I have one key: even if the library is used to compile the application, it is not copied to the apk file. I unpacked apk and it includes 2 files in lib \ x86: gdbserver and libAndroid1.so (which is a compiled version of my own action). But the library I linked just doesn't exist.

I suppose I should indicate somewhere in the project that I want my library to be included in apk, but where do I do it?

+4
source share
1 answer

Step 2 should actually be: Add the path lib \ $ (Platform) to Linker-> General-> Additional Library Directories

I doubt that x86 is running on your Android device (unless it is in the emulator). $ (Configuration) will automatically enable Debug or Release, and $ (Platform) will automatically enable ARM, ARM64, x86, etc.

You have a separate folder for each library.

0
source