我有一个NDK项目,我需要与一些C文件进行通信。 在我的项目中,我将所有C文件放在一个地方但是当我尝试从我的项目中的一个C文件中调用一个函数时 - 我得到了"未定义的引用到' locationEngine'。 / p>
我的wrapper.c文件试图调用' locationEngine' locationEngine.c文件中的函数。
我已经添加了#include" locationEngine.h"在我的wrapper.c中,所以它应该有一个引用!
我唯一能想到的可能是CMakeLists.txt没有定义什么?
这里的wrapper.c:
#include <jni.h>
#include "locationEngine_types.h"
#include "locationEngine.h"
... removed for brevity
{
// build struct0_T from our POJO LocationStruct that is passed in
struct0_T input = buildLocationStruct(env, locationStruct);
// add the default locEngParams
input.locEngParams = locEngParams;
// add user params - first time it's an initialized struct with all 0's;
input.userParams = userParam;
// pass a reference to them
locationEngine(&input, &output);
}
这是CMakeLists.txt:
cmake_minimum_required(VERSION 3.4.1)
add_library(wrapper SHARED
wrapper.c)
# Include libraries needed for wrapper lib
target_link_libraries(wrapper
android
log)
这是wrapper.h
#include "../../../../../Library/Android/sdk/ndk-bundle/platforms/android-14/arch-arm/usr/include/jni.h"
#include "locationEngine_types.h"
#include "locationEngine.h"
#ifndef LOCATIONENGINE_WRAPPER_H
#define LOCATIONENGINE_WRAPPER_H
struct0_T extractLocationStruct(JNIEnv *env, jobject locationStruct);
void init();
void destroy();
void start();
void stop();
#endif //LOCATIONENGINE_WRAPPER_H
P.S - 我是C代码的新手。