[英]how do I use pre_built library
let say I have this piece of code: 假设我有这段代码:
print.cpp print.cpp
int print ()
{
return 10;
}
print.h print.h
#ifndef PRINT_H
#define PRINT_H
int print(); // function prototype for add.h
#endif
I compiled into a library call libTest.a 我编译成一个库调用libTest.a
now let say i have this android.mk file 现在说我有这个android.mk文件
include $(CLEAR_VARS)
LOCAL_MODULE := libtest
LOCAL_SRC_FILES := ../issmlib/libTest.a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../include
include $(PREBUILT_STATIC_LIBRARY)
of course there is others thing like shared, but assumed they all work fine!!! 当然,还有其他类似共享的东西,但是假设它们都可以正常工作!!! I put libTest.a in a folder called issmlib and it is in my project same level as jni folder I then put print.h into a folder called include.
我将libTest.a放在名为issmlib的文件夹中,它在我的项目中与jni文件夹处于同一级别,然后将print.h放入名为include的文件夹中。
now this is my main: 现在这是我的主要:
#include "com_lan_factorial_FacLib.h"
#include "fac.h"
//extern long fac(long n);
JNIEXPORT jlong JNICALL Java_com_lan_factorial_FacLib_fac(JNIEnv *env, jclass clazz, jlong n)
{
fac *f = new fac();
jlong result = (jlong) (f->factorial(n));
delete(f);
return result + print();
}
so what it does it compute the result and add 10 to it. 因此它会计算结果并将结果加10。 I do not know how to use that pre-built library, do i have to state #include "print.h" I did put it in but it complains that no implementation of the method.
我不知道如何使用该预先构建的库,我是否必须声明我确实将其放入的#include“ print.h”,但它抱怨该方法没有实现。 When I take it out, it complains that no print() have been declared.
当我取出它时,它抱怨没有声明print()。
This is much of a C++ question, but hopefully you can help. 这大部分是C ++问题,但希望可以为您提供帮助。
I believe my pathing for Android.mk is fine, but if you spot something wierd, please let me know. 我相信我使用Android.mk的方法很好,但是如果发现异常,请告诉我。 Thanks alot.
非常感谢。
Make sure that you have V=1
parameter on the ndk-build
command line. 确保在
ndk-build
命令行上有V=1
参数。 This way, you will see the actual compilation commands as the are prepared by ndk-build. 这样,您将看到由ndk-build准备的实际编译命令。 This often gives a clue as to what is wrong with the path definitions in
Android.mk
. 这通常可以提供关于
Android.mk
的路径定义出了什么问题的线索。
If you need help interpreting this log, leave a comment here and edit the question to include the full build log and the full Android.mk
, including the part that invokes BUILD_SHARED_LIBRARY 如果您需要帮助解释此日志,请在此处留下评论,然后编辑问题以包括完整的构建日志和完整的
Android.mk
,其中包括调用BUILD_SHARED_LIBRARY的部分
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.