Open dahai2070 opened 4 years ago
同问
我也是一样的
Task :app:externalNativeBuildDebug Build native-lib_armeabi-v7a [1/7] Building CXX object src/main/cpp/alignment/CMakeFiles/seeta_fa_lib.dir/sift.cpp.o [2/7] Building CXX object src/main/cpp/alignment/CMakeFiles/seeta_fa_lib.dir/face_alignment.cpp.o [3/7] Building CXX object src/main/cpp/alignment/CMakeFiles/seeta_fa_lib.dir/cfan.cpp.o clang++: warning: argument unused during compilation: '-msse4.1' [-Wunused-command-line-argument] clang++: warning: argument unused during compilation: '-msse4.1' [-Wunused-command-line-argument] clang++: warning: argument unused during compilation: '-msse4.1' [-Wunused-command-line-argument] [4/7] Linking CXX shared library ........\build\intermediates\cmake\debug\obj\armeabi-v7a\libseeta_fa_lib.so [5/7] Building CXX object CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o [6/7] Building CXX object CMakeFiles/native-lib.dir/src/main/cpp/FaceTracker.cpp.o clang++: warning: argument unused during compilation: '-L/D:/kalading/ProJect/GitHub/OpenGlCameraRender/app/src/main/jniLibs/armeabi-v7a' [-Wunused-command-line-argument] clang++: warning: argument unused during compilation: '-L/D:/kalading/ProJect/GitHub/OpenGlCameraRender/app/src/main/jniLibs/armeabi-v7a' [-Wunused-command-line-argument] [7/7] Linking CXX shared library ........\build\intermediates\cmake\debug\obj\armeabi-v7a\libnative-lib.so FAILED: cmd.exe /C "cd . && C:\Develop\Android\sdk\ndk\22.0.6917172\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe --target=armv7-none-linux-androideabi21 --gcc-toolchain=C:/Develop/Android/sdk/ndk/22.0.6917172/toolchains/llvm/prebuilt/windows-x86_64 --sysroot=C:/Develop/Android/sdk/ndk/22.0.6917172/toolchains/llvm/prebuilt/windows-x86_64/sysroot -fPIC -L/D:/kalading/ProJect/GitHub/OpenGlCameraRender/app/src/main/jniLibs/armeabi-v7a -O0 -fno-limit-debug-info -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libgcc_real.a -Wl,--exclude-libs,libatomic.a -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--fatal-warnings -Wl,--exclude-libs,libunwind.a -Wl,--no-undefined -Qunused-arguments -shared -Wl,-soname,libnative-lib.so -o ........\build\intermediates\cmake\debug\obj\armeabi-v7a\libnative-lib.so CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/FaceTracker.cpp.o ../../../../build/intermediates/cmake/debug/obj/armeabi-v7a/libseeta_fa_lib.so -lopencv_java4 -landroid -llog -latomic -lm && cd ." ld: error: unable to find library -lopencv_java4 clang++: error: linker command failed with exit code 1 (use -v to see invocation) ninja: build stopped: subcommand failed.
Task :app:externalNativeBuildDebug FAILED
ld: error: unable to find library -lopencv_java4
没导入ndk路径
修改app/CMakeLists.txt 去掉链接目录-L的第一个斜杠就可
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_GLAGS} -L${CMAKE_SOURCE_DIR}/src/main/jniLibs/${ANDROID_ABI}")
Execution failed for task ':app:externalNativeBuildDebug'.
Build command failed. Error while executing process D:\Android\sdk\cmake\3.6.4111459\bin\cmake.exe with arguments {--build E:\OpenGlCameraRender\app.cxx\cmake\debug\armeabi-v7a --target native-lib} [1/3] Building CXX object CMakeFiles/native-lib.dir/src/main/cpp/FaceTracker.cpp.o [2/3] Building CXX object CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o clang++: warning: argument unused during compilation: '-L/E:/OpenGlCameraRender/app/src/main/jniLibs/armeabi-v7a' [-Wunused-command-line-argument]
救命啊
修改app/CMakeLists.txt文件如下,即可
@2014gaokao
@yeocci 好哥哥,我在windows上改成这样后报如下错了 Execution failed for task ':app:externalNativeBuildDebug'.
Build command failed. Error while executing process D:\Android\sdk\cmake\3.6.4111459\bin\cmake.exe with arguments {--build E:\OpenGlCameraRender\app.cxx\cmake\debug\armeabi-v7a --target native-lib}
但我今早在ubuntu上跑代码不用改都不报错,只不过进app就闪退了。然后又按照你的改了下也报了同样的错误。
@2014gaokao 那你肯定没按我截图的做好,请再次检查set_target_properties最后一个参数的路径
闪退的问题可能是模型文件没有正确释放,模型文件在GlRenderWrapper下被释放并初始化,修改释放路径即可。
Build command failed. Error while executing process C:\Users\dahai\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\cmake.exe with arguments {--build C:\Users\dahai\StudioProjects\OpenGlCameraRender\app.cxx\cmake\debug\armeabi-v7a --target native-lib} [1/7] Building CXX object src/main/cpp/alignment/CMakeFiles/seeta_fa_lib.dir/sift.cpp.o [2/7] Building CXX object src/main/cpp/alignment/CMakeFiles/seeta_fa_lib.dir/face_alignment.cpp.o [3/7] Building CXX object src/main/cpp/alignment/CMakeFiles/seeta_fa_lib.dir/cfan.cpp.o clang++: warning: argument unused during compilation: '-msse4.1' [-Wunused-command-line-argument]
clang++: warning: argument unused during compilation: '-msse4.1' [-Wunused-command-line-argument]
clang++: warning: argument unused during compilation: '-msse4.1' [-Wunused-command-line-argument]
[4/7] Linking CXX shared library ........\build\intermediates\cmake\debug\obj\armeabi-v7a\libseeta_fa_lib.so [5/7] Building CXX object CMakeFiles/native-lib.dir/src/main/cpp/FaceTracker.cpp.o [6/7] Building CXX object CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o clang++: warning: argument unused during compilation: '-L/C:/Users/dahai/StudioProjects/OpenGlCameraRender/app/src/main/jniLibs/armeabi-v7a' [-Wunused-command-line-argument]
clang++: warning: argument unused during compilation: '-L/C:/Users/dahai/StudioProjects/OpenGlCameraRender/app/src/main/jniLibs/armeabi-v7a' [-Wunused-command-line-argument]
[7/7] Linking CXX shared library ........\build\intermediates\cmake\debug\obj\armeabi-v7a\libnative-lib.so FAILED: cmd.exe /C "cd . && C:\Users\dahai\AppData\Local\Android\Sdk\ndk\21.0.6113669\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe --target=armv7-none-linux-androideabi21 --gcc-toolchain=C:/Users/dahai/AppData/Local/Android/Sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/windows-x86_64 --sysroot=C:/Users/dahai/AppData/Local/Android/Sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/windows-x86_64/sysroot -fPIC -L/C:/Users/dahai/StudioProjects/OpenGlCameraRender/app/src/main/jniLibs/armeabi-v7a -O0 -fno-limit-debug-info -Wl,--exclude-libs,libgcc_real.a -Wl,--exclude-libs,libatomic.a -Wl,--build-id -Wl,--fatal-warnings -Wl,--exclude-libs,libunwind.a -Wl,--no-undefined -Qunused-arguments -shared -Wl,-soname,libnative-lib.so -o ........\build\intermediates\cmake\debug\obj\armeabi-v7a\libnative-lib.so CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/FaceTracker.cpp.o ../../../../build/intermediates/cmake/debug/obj/armeabi-v7a/libseeta_fa_lib.so -lopencv_java4 -landroid -llog -latomic -lm && cd ." C:/Users/dahai/AppData/Local/Android/Sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/windows-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin\ld: error: cannot find -lopencv_java4
CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o:native-lib.cpp:function Java_com_example_cameraglrender_face_FaceTracker_native_1detector: error: undefined reference to 'cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int)'
CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o:native-lib.cpp:function Java_com_example_cameraglrender_face_FaceTracker_native_1detector: error: undefined reference to 'cv::rotate(cv::_InputArray const&, cv::_OutputArray const&, int)'
CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o:native-lib.cpp:function Java_com_example_cameraglrender_face_FaceTracker_native_1detector: error: undefined reference to 'cv::flip(cv::_InputArray const&, cv::_OutputArray const&, int)'
CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o:native-lib.cpp:function Java_com_example_cameraglrender_face_FaceTracker_native_1detector: error: undefined reference to 'cv::rotate(cv::_InputArray const&, cv::_OutputArray const&, int)'
CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o:native-lib.cpp:function Java_com_example_cameraglrender_face_FaceTracker_native_1detector: error: undefined reference to 'cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int)'
CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o:native-lib.cpp:function Java_com_example_cameraglrender_face_FaceTracker_native_1detector: error: undefined reference to 'cv::equalizeHist(cv::_InputArray const&, cv::_OutputArray const&)'
CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o:native-lib.cpp:function cv::Mat::Mat(int, int, int, void, unsigned int): error: undefined reference to 'cv::error(int, std::ndk1::basic_string<char, std::__ndk1::char_traits, std:: ndk1::allocator > const&, char const , char const*, int)'
CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o:native-lib.cpp:function cv::Mat::Mat(int, int, int, void, unsigned int): error: undefined reference to 'cv::error(int, std::ndk1::basic_string<char, std::__ndk1::char_traits, std:: ndk1::allocator > const&, char const , char const*, int)'
CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o:native-lib.cpp:function cv::Mat::Mat(int, int, int, void*, unsigned int): error: undefined reference to 'cv::Mat::updateContinuityFlag()'
CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o:native-lib.cpp:function cv::Mat::Mat(cv::Mat const&): error: undefined reference to 'cv::Mat::copySize(cv::Mat const&)'
CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o:native-lib.cpp:function cv::Mat::~Mat(): error: undefined reference to 'cv::fastFree(void*)'
CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o:native-lib.cpp:function cv::Mat::release(): error: undefined reference to 'cv::Mat::deallocate()'
CMakeFiles/native-lib.dir/src/main/cpp/FaceTracker.cpp.o:FaceTracker.cpp:function FaceTracker::FaceTracker(char const, char const): error: undefined reference to 'cv::DetectionBasedTracker::Parameters::Parameters()'
CMakeFiles/native-lib.dir/src/main/cpp/FaceTracker.cpp.o:FaceTracker.cpp:function std::ndk1::shared_ptr_emplace<cv::CascadeClassifier, std::ndk1::allocator >:: on_zero_shared(): error: undefined reference to 'cv::CascadeClassifier::~CascadeClassifier()'
CMakeFiles/native-lib.dir/src/main/cpp/FaceTracker.cpp.o:FaceTracker.cpp:function std::ndk1::compressed_pair_elem<cv::CascadeClassifier, 1, false>::compressed_pair_elem<char const* const&, 0u>(std::ndk1::piecewise_construct_t, std::ndk1::tuple<char const* const&>, std::ndk1::tuple_indices<0u>): error: undefined reference to 'cv::CascadeClassifier::CascadeClassifier(std::__ndk1::basic_string<char, std::ndk1::char_traits, std::__ndk1::allocator > const&)'
CMakeFiles/native-lib.dir/src/main/cpp/FaceTracker.cpp.o:FaceTracker.cpp:function std::ndk1::compressed_pair_elem<cv::CascadeClassifier, 1, false>::~__compressed_pair_elem(): error: undefined reference to 'cv::CascadeClassifier::~CascadeClassifier()'
CMakeFiles/native-lib.dir/src/main/cpp/FaceTracker.cpp.o:FaceTracker.cpp:function CascadeDetectorAdapter::CascadeDetectorAdapter(cv::Ptr): error: undefined reference to 'cv::error(int, std::ndk1::basic_string<char, std::__ndk1::char_traits, std:: ndk1::allocator > const&, char const, char const, int)'
CMakeFiles/native-lib.dir/src/main/cpp/FaceTracker.cpp.o:FaceTracker.cpp:function CascadeDetectorAdapter::detect(cv::Mat const&, std::ndk1::vector<cv::Rect_, std::ndk1::allocator<cv::Rect_ > >&): error: undefined reference to 'cv::CascadeClassifier::detectMultiScale(cv::_InputArray const&, std:: ndk1::vector<cv::Rect_, std:: ndk1::allocator<cv::Rect > >&, double, int, int, cv::Size , cv::Size_)'
CMakeFiles/native-lib.dir/src/main/cpp/FaceTracker.cpp.o:FaceTracker.cpp:function std::ndk1::compressed_pair_elem<cv::DetectionBasedTracker, 1, false>::compressed_pair_elem<cv::Ptr const&, cv::Ptr const&, cv::DetectionBasedTracker::Parameters const&, 0u, 1u, 2u>(std:: ndk1::piecewise_construct_t, std::ndk1::tuple<cv::Ptr const&, cv::Ptr const&, cv::DetectionBasedTracker::Parameters const&>, std:: ndk1::__tuple_indices<0u, 1u, 2u>): error: undefined reference to 'cv::DetectionBasedTracker::DetectionBasedTracker(cv::Ptr, cv::Ptr, cv::DetectionBasedTracker::Parameters const&)'
CMakeFiles/native-lib.dir/src/main/cpp/FaceTracker.cpp.o:FaceTracker.cpp:function std::ndk1::compressed_pair_elem<cv::DetectionBasedTracker, 1, false>::~__compressed_pair_elem(): error: undefined reference to 'cv::DetectionBasedTracker::~DetectionBasedTracker()'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.