为什么Android NDK log.h __android_log_print链接错误
why Android NDK log.h __android_log_print linker error
我尝试使用__android_log_print。但是出现了链接错误。我使用了makefile Android。可:-
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := com_test_JniTest.cpp
LOCAL_MODULE := com_test_JniTest
LOCAL_LDLIBS += -llog
include $(BUILD_SHARED_LIBRARY)
我得到错误:-
/用户/abc/AndroidStudioProjects/测试/app/src/main/jni/com_test_JniTest.cpp错误:(29)未定义对' __android_log_print'的引用
如何链接和使用__android_log_print ?
可能是路径的问题。
搜索liblog的路径。所以在你的系统中设置如下:
LOCAL_LDLIBS := -L<path to liblog.so> -llog
例如:LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog
或者如果你使用Gradle,你必须在build.gradle
中指定libandroid {
defaultConfig {
ndk {
moduleName "whatever"
ldLibs "log"
}
}
}
相关文章:
- 如何用数字处理log(0)
- 安装opencv失败-粘贴CMakeError.log的内容
- 犰狳的 print() 方法和 cout 在从 Rcpp 调用时顺序不一致
- 保持排序的数据结构,允许log N插入时间,并且可以返回我在log N中查找的元素的索引
- 如何在不进行任何其他修改的情况下"pretty print" C++的XML字符串?
- boost日志文件无法创建sample.log文件
- pybind11将python sys.stdout从print()重定向到c++
- Boost::log只在debian中崩溃
- 如何检查 2 个 c++ 数组在 O(1) 或 O(log n) 时间复杂度中是否相同(所有元素都相同,顺序很重要)?
- 设置自定义收集器时不会提升::log尊重关键字::max_size吗?
- Serial.print in arduino 不写变量
- 我仍然收到此错误未定义的引用:boost::log::v2_mt_posix::trivial::logger::get
- 增强.log含义和功能
- log in cpp 14 and 17
- constexpr exp, log, pow
- 如何递归"print list from tail to head"?
- Boost Log的琐碎记录器"lazy evaluation"是如何工作的?
- boost::log 设置"Channel"通道记录器中的属性
- V8 控制台.log不打印
- Boost Log:变量不是"boost::log::v2s_mt_posix::trivial"的