你好,我想请问一下:
我拿ncnn编译出来的.a文件,用ndk-build编译.so的时候会报
undefined reference to '__kmpc_fork_call'
undefined reference to '__kmpc_for_static_init_4'
undefined reference to '__kmpc_for_static_fini'
undefined reference to '__kmpc_for_static_init_4'
layer/convolutiondepthwise.cpp:176: error:undefined reference to '__kmpc_for_static_init_8'
LOCAL_CFLAGS += -fopenmp
LOCAL_CPPFLAGS += -fopenmp
LOCAL_LDFLAGS += -fopenmp
参考 https://github.com/Tencent/ncnn/blob/master/examples/squeezencnn/jni/Android.mk
你好,谢谢你的回复。但是我有点看不明白。您的意思是我少了这三行代码吗?我的Android.mk文件里有这三行代码的,是我少了什么库吗?
你好,还有一个问题,我编译出来的libncnn.a有4560KB,而你们给出的libncnn.a不到1000KB,请问是什么原因呢?我是按照https://github.com/Tencent/ncnn/wiki/how-to-build这里面的步骤进行编译的。如果方便请回复一下。
android ndk 自带的cmake toolchain自动加上了 -g 编译,把 toolchain cmake 里的 -g 删掉重新编译一次就小了
android ndk 版本用 r15c 或者更新的
请问解决了吗?我也是碰到了同样的问题,build.sh发生了变化,现在用的是ndk自带的toolchain cmake,请问在编译的时候需要修改toolchain cmake里面的内容以支持openmp吗?
我没有修改toolchain cmake里面的东西,我修改了.build.sh里面的东西就编译ok了。
新版使用了 android-ndk clang 编译器编译,openmp 运行时库对应于 libomp.a
@nihui, can be the ncnn static library libncnn.a compiled with APP_STL :=c++_static . The released version is compiled with gnustl_static?
@nihui, when i was packing libncnn.a into shared library with other libraries by settings stl as c++_static. it threw errors like:
/home/nihui/osd/ncnn/src/modelbin.cpp:(.text._ZNSt6vectorIhSaIhEE14_M_fill_insertEN9__gnu_cxx17__normal_iteratorIPhS1_EEmRKh[_ZNSt6vectorIhSaIhEE14_M_fill_insertEN9__gnu_cxx17__normal_iteratorIPhS1_EEmRKh]+0x1bc): undefined reference to `std::__throw_length_error(char const*)'.
This seems like gnustl dependencies
these errors were fixed by rebuilt ncnn library with c++_static stl.
open Application.mk
APP_STL := gnustl_static
APP_ABI := armeabi-v7a
APP_PLATFORM := android-9
I solve this error like this:
@nihui, 我用新版本出现类似的错误
Error:error: ld returned 1 exit status
Error:error: undefined reference to '__kmpc_fork_call'
我使用的是Android studio的cmake方式进行调用,请问如何解决,具体的指令我没有找到
it has .so file after commend this line
but after commented NDK_TOOLCHAIN_VERSION := 4.9, the .so will be Invalid
你好,谢谢你的回复。但是我有点看不明白。您的意思是我少了这三行代码吗?我的Android.mk文件里有这三行代码的,是我少了什么库吗?
我这边也是添加了这三行code,还是不行,请问你是怎么解决的呢?
LOCAL_CFLAGS + = -fopenmp
LOCAL_CPPFLAGS + = -fopenmp
LOCAL_LDFLAGS + = -fopenmp参考https://github.com/Tencent/ncnn/blob/master/examples/squeezencnn/jni/Android.mk
我添加了这个,还是报错,是需要openmp这个库吗?
我没有修改toolchain cmake里面的东西,我修改了.build.sh里面的东西就编译ok了。
你好,请问怎么修改呢,谢谢啊
these errors were fixed by rebuilt ncnn library with c++_static stl.
@bobby-chiu
hello, if i want to rebuilt ncnn library with c++_static stl, what i need to modify?
than you
Most helpful comment
open Application.mk
APP_STL := stlport_static
APP_STL := gnustl_static
APP_ABI := armeabi armeabi-v7a
APP_ABI := armeabi-v7a
APP_PLATFORM := android-9
NDK_TOOLCHAIN_VERSION := 4.9
I solve this error like this:
NDK_TOOLCHAIN_VERSION := 4.9 >>>>> #NDK_TOOLCHAIN_VERSION := 4.9