当前位置:   article > 正文

ncnn使用GPU时报error: undefined reference to *******_ncnn::vkweightallocator::fastfree(ncnn::vkimagemem

ncnn::vkweightallocator::fastfree(ncnn::vkimagememory*): error: undefined re

导读

根据ncnn的官方教程使用vulkan-sdk编译了一个带gpu功能的libncnn.a库,官方教程如下:

https://github.com/Tencent/ncnn/wiki/how-to-build#build-for-windows-x64-using-visual-studio-community-2017

详细错误

  1. ../../../../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'
  2. ../../../../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'
  3. ../../../../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'
  4. ../../../../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'
  5. ../../../../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'
  6. ../../../../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'
  7. ../../../../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'
  8. ../../../../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'
  9. ../../../../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'
  10. ../../../../src/main/cppLibs/ncnn/lib/armeabi-v7a/libncnn.a(allocator.cpp.o):allocator.cpp:function ncnn::VkBlobBufferAllocator::clear(): error: undefined reference to 'vkDestroyBuffer'
  11. ../../../../src/main/cppLibs/ncnn/lib/armeabi-v7a/libncnn.a(allocator.cpp.o):allocator.cpp:function ncnn::VkBlobBufferAllocator::clear(): error: undefined reference to 'vkFreeMemory'
  12. ../../../../src/main/cppLibs/ncnn/lib/armeabi-v7a/libncnn.a(allocator.cpp.o):allocator.cpp:function ncnn::VkBlobBufferAllocator::clear(): error: undefined reference to 'vkUnmapMemory'
  13. ../../../../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.gradleCMakeLists.txt文件来进行配置的,如果你是使用的Android.mkapplication.mk文件可能配置上会有些区别

  • build.gradle文件中添加以下内容

想要使用GPU功能,Android的版本必须在24(Android7.0)以上

  1. android {
  2. defaultConfig {
  3. minSdkVersion 24//应用支持Android的最低版本
  4. externalNativeBuild {
  5. cmake {
  6. arguments "-DANDROID_PLATFORM=android-24"//设置编译so文件的时候Android的版本
  7. }
  8. }
  9. }
  10. }
  • CMakeLists.txt文件中添加如下内容
  1. target_link_libraries( # Specifies the target library.
  2. jnigraphics
  3. vulkan)
  • Android.mk文件添加如下内容
LOCAL_LDLIBS := -lz -llog -ljnigraphics -lvulkan -landroid

application.mk中添加

APP_PLATFORM := android-24

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/703297
推荐阅读
相关标签
  

闽ICP备14008679号