出现错误:未定义对功能Android NDK的引用 [英] Getting error: undefined reference to function Android NDK
问题描述
我已经尝试解决此问题超过两天了,但还是没有运气.
I have been trying to solve this issue for more than two days, but still no luck.
我不知道出什么问题了,我只需要建立一个简单的NDK项目,但是这已经花费了很多时间.
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.
问题是我正在
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)'
这是我的根CMakeLists
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)
在libs目录中
# 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.
这是源代码,因此您可以看到它们的全部结构. https://github.com/DurianOdour/EcgProcessor
Here is source code, so you can see it all structured. https://github.com/DurianOdour/EcgProcessor
感谢您的帮助
推荐答案
我已经找到解决方案.这是
I Have found the solution. Here it is
Android ndk(cmake):在第二个jni库中使用log api时未定义对__android_log_write的引用
问题在于链接库的顺序不正确.
The problem was in the incorrect order of linking libraries.
这段代码很好用
# 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>] ...)
这篇关于出现错误:未定义对功能Android NDK的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!