导读
根据ncnn的官方教程使用vulkan-sdk编译了一个带gpu功能的libncnn.a库,官方教程如下:
https://github.com/Tencent/ncnn/wiki/how-to-build#build-for-windows-x64-using-visual-studio-community-2017
详细错误
../../../../src/main/cppLibs/ncnn/lib/armeabi-v7a/libncnn.a(modelbin.cpp.o):modelbin.cpp:function ncnn::ModelBinFromDataReader::load(int, int) const: error: undefined reference to 'stderr'
../../../../src/main/cppLibs/ncnn/lib/armeabi-v7a/libncnn.a(modelbin.cpp.o):modelbin.cpp:function ncnn::ModelBinFromDataReader::load(int, int) const: error: undefined reference to 'stderr'
../../../../src/main/cppLibs/ncnn/lib/armeabi-v7a/libncnn.a(modelbin.cpp.o):modelbin.cpp:function ncnn::ModelBinFromDataReader::load(int, int) const: error: undefined reference to 'stderr'
../../../../src/main/cppLibs/ncnn/lib/armeabi-v7a/libncnn.a(modelbin.cpp.o):modelbin.cpp:function ncnn::ModelBinFromDataReader::load(int, int) const: error: undefined reference to 'stderr'
../../../../src/main/cppLibs/ncnn/lib/armeabi-v7a/libncnn.a(allocator.cpp.o):allocator.cpp:function ncnn::VkAllocator::flush(ncnn::VkBufferMemory*): error: undefined reference to 'vkFlushMappedMemoryRanges'
../../../../src/main/cppLibs/ncnn/lib/armeabi-v7a/libncnn.a(allocator.cpp.o):allocator.cpp:function ncnn::VkAllocator::invalidate(ncnn::VkBufferMemory*): error: undefined reference to 'vkInvalidateMappedMemoryRanges'
../../../../src/main/cppLibs/ncnn/lib/armeabi-v7a/libncnn.a(allocator.cpp.o):allocator.cpp:function ncnn::VkAllocator::create_buffer(unsigned int, unsigned int): error: undefined reference to 'vkCreateBuffer'
../../../../src/main/cppLibs/ncnn/lib/armeabi-v7a/libncnn.a(allocator.cpp.o):allocator.cpp:function ncnn::VkAllocator::allocate_memory(unsigned int): error: undefined reference to 'vkAllocateMemory'
../../../../src/main/cppLibs/ncnn/lib/armeabi-v7a/libncnn.a(allocator.cpp.o):allocator.cpp:function ncnn::VkAllocator::allocate_dedicated_memory(unsigned int, unsigned long long): error: undefined reference to 'vkAllocateMemory'
../../../../src/main/cppLibs/ncnn/lib/armeabi-v7a/libncnn.a(allocator.cpp.o):allocator.cpp:function ncnn::VkBlobBufferAllocator::clear(): error: undefined reference to 'vkDestroyBuffer'
../../../../src/main/cppLibs/ncnn/lib/armeabi-v7a/libncnn.a(allocator.cpp.o):allocator.cpp:function ncnn::VkBlobBufferAllocator::clear(): error: undefined reference to 'vkFreeMemory'
../../../../src/main/cppLibs/ncnn/lib/armeabi-v7a/libncnn.a(allocator.cpp.o):allocator.cpp:function ncnn::VkBlobBufferAllocator::clear(): error: undefined reference to 'vkUnmapMemory'
../../../../src/main/cppLibs/ncnn/lib/armeabi-v7a/libncnn.a(allocator.cpp.o):allocator.cpp:function ncnn::VkBlobBufferAllocator::fastMalloc(unsigned int): error: undefined reference to 'vkCreateBuffer'
解决办法
我在编译Android工程的时候,采用的是build.gradle和CMakeLists.txt文件来进行配置的,如果你是使用的Android.mk和application.mk文件可能配置上会有些区别
- build.gradle文件中添加以下内容
想要使用GPU功能,Android的版本必须在24(Android7.0)以上
android {
defaultConfig {
minSdkVersion 24//应用支持Android的最低版本
externalNativeBuild {
cmake {
arguments "-DANDROID_PLATFORM=android-24"//设置编译so文件的时候Android的版本
}
}
}
}
- CMakeLists.txt文件中添加如下内容
target_link_libraries( # Specifies the target library.
jnigraphics
vulkan)
- Android.mk文件添加如下内容
LOCAL_LDLIBS := -lz -llog -ljnigraphics -lvulkan -landroid
application.mk中添加
APP_PLATFORM := android-24
最后
以上就是无情龙猫最近收集整理的关于ncnn使用GPU时报error: undefined reference to *******的全部内容,更多相关ncnn使用GPU时报error:内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复