Android NDK how to include library properly, header files

1.8k views Asked by At

I am just starting to grasp NDK with Android.

I am trying to include library header files and therefore compile a third party library as a dependency with my project.

However I am not able to include the library, and I feel that I am doing this wrong.

My project structure

jni
--mylib.cpp
--CMakeLists.txt
----libs
------firpm_d
--------CMakeLists.txt
--------src
--------include
----------firpm
------------pm.h

My CMakeLists.txt looks as follows

# Cmake Minimum Version
cmake_minimum_required(VERSION 3.4.1)
project(MyLib)

# Add libraries

FOREACH(subdir ${SUBDIRS})
  ADD_SUBDIRECTORY(${subdir})
ENDFOREACH()

add_library(mylib SHARED
            mylib.cpp)

# Link
target_link_libraries(
            mylib
            android
            log)

And in my mylib.cpp file I am including the third party lib as follows

#include "lib/firpm_d/include/firpm/pm.h"

But when I try to compile it gives me an error

Error:(25) undefined reference to 'firpm(unsigned int, std::vector<double, std::allocator<double> > const&, std::vector<double, std::allocator<double> > const&, std::vector<double, std::allocator<double> > const&, double, int)'

Maybe I need to set LOCAL_C_INCLUDES, but I haven't found any information how to do this with new build tools and CMake

And by the way Android Studio doesn't highlight any line as problematic.

I would be grateful for any help or advice.

0

There are 0 answers