0

I have been trying to solve this issue for more than two days, but still no luck.

I have no idea what is wrong, I need just to set up a simple NDK project, but it has already taken a tremendous amount of time.

The problem is that I am getting

error: 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)'

Here is my root CMakeLists

# Cmake Minimum Version
cmake_minimum_required(VERSION 3.4.1)
project(EcgProcessing)
# Add nested cmake files
include(libs/CMakeLists.txt)

include_directories(${CMAKE_CURRENT_SOURCE_DIR})

# ECG Audio Processor library
add_library(ecg-signal-processor-demodulator SHARED
            demodulator.cpp)
add_library(ecg-signal-processor-qrsdetection SHARED
            qrsdetection.cpp)
# Link

target_link_libraries(
            firpm_d
            log
            android
            ecg-signal-processor-demodulator
            ecg-signal-processor-qrsdetection)

And in the libs directory

# Cmake Minimum Version
cmake_minimum_required(VERSION 3.4.1)
set(LIBS_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})
#include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Eigen/)
MACRO(ADD_SUBLIB libname source_ext)
  #Compute required sources
  set(sublib_path "${LIBS_DIRECTORY}/${libname}")
  file(GLOB_RECURSE sublib_sources "${sublib_path}/src/*.${source_ext}")
  #Create library
  IF( sublib_sources )
    ADD_LIBRARY(${libname} SHARED ${sublib_sources})
  ENDIF()
  #add this library's header folder to the global include set
  INCLUDE_DIRECTORIES("${sublib_path}/include")
  INCLUDE_DIRECTORIES("${sublib_path}/")
  link_directories(${sublib_path})
ENDMACRO(ADD_SUBLIB)

ADD_SUBLIB(firpm_d "cpp")
ADD_SUBLIB(eigen "cpp")

It starts to compile the project, however ends up with the error.

What can cause this error, I have no idea what to try else.

Here is source code, so you can see it all structured. https://github.com/DurianOdour/EcgProcessor

I would be grateful for any help

4
  • 1
    You are obviously not linking whatever defines the firpm symbol. Or you are linking things in incorrect order, so the symbol is not seen by the linker before the objct file or library that provides it (yes, link order matters). Commented Nov 19, 2017 at 12:54
  • @JesperJuhl, thank you for your comment, I am including firpm header file as well as source files using ADD_SUBLIB macro, this function is located in pm.h file. Commented Nov 19, 2017 at 12:56
  • the header doesn't matter here. What matters is the file implementing the function and where it occurs on the link line relative to the file that uses it. Files using a symbol must (generally) be mentioned before the files providing the symbol. Commented Nov 19, 2017 at 12:58
  • @JesperJuhl, I have added source files as well file(GLOB_RECURSE sublib_sources "${sublib_path}/src/*.${source_ext}") Commented Nov 19, 2017 at 13:18

1 Answer 1

1

I Have found the solution. Here it is

Android ndk(cmake): 'undefined reference to `__android_log_write' when using log api in the second jni library

The problem was in the incorrect order of linking libraries.

This code works great

# Link
target_link_libraries(
            ecg-signal-processor
            log
            android
            firpm_d)

The first arguments should be a library that requires dependencies.

target_link_libraries(<target> [item1 [item2 [...]]]
                      [[debug|optimized|general] <item>] ...)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.