ORB-SLAM2-based-AR-on-Android icon indicating copy to clipboard operation
ORB-SLAM2-based-AR-on-Android copied to clipboard

undefined reference to `cv::FAST` when build using cmake and make

Open PapaMadeleine2022 opened this issue 4 years ago • 8 comments

hello, when I build your code using cmake and make in app folder, it shows error:

/xxx/ORB-SLAM2-based-AR-on-Android/app/src/main/cpp/ORB/src/ORBextractor.cc:812: undefined reference to `cv::FAST(cv::_InputArray const&, std::__ndk1::vector<cv::KeyPoint, std::__ndk1::allocator<cv::KeyPoint> >&, int, bool)'
/xxx/ORB-SLAM2-based-AR-on-Android/app/src/main/cpp/ORB/src/ORBextractor.cc:817: undefined reference to `cv::FAST(cv::_InputArray const&, std::__ndk1::vector<cv::KeyPoint, std::__ndk1::allocator<cv::KeyPoint> >&, int, bool)'
libORBSLAM2.a(ORBextractor.cc.o): In function `ORB_SLAM2::ORBextractor::ComputeKeyPointsOctTree(std::__ndk1::vector<std::__ndk1::vector<cv::KeyPoint, std::__ndk1::allocator<cv::KeyPoint> >, std::__ndk1::allocator<std::__ndk1::vector<cv::KeyPoint, std::__ndk1::allocator<cv::KeyPoint> > > >&)':
/xxx/ORB-SLAM2-based-AR-on-Android/app/src/main/cpp/ORB/src/ORBextractor.cc:917: undefined reference to `cv::FAST(cv::_InputArray const&, std::__ndk1::vector<cv::KeyPoint, std::__ndk1::allocator<cv::KeyPoint> >&, int, bool)'
/xxx/ORB-SLAM2-based-AR-on-Android/app/src/main/cpp/ORB/src/ORBextractor.cc:922: undefined reference to `cv::FAST(cv::_InputArray const&, std::__ndk1::vector<cv::KeyPoint, std::__ndk1::allocator<cv::KeyPoint> >&, int, bool)'
libORBSLAM2.a(ORBextractor.cc.o): In function `ORB_SLAM2::ORBextractor::ComputeKeyPointsOld(std::__ndk1::vector<std::__ndk1::vector<cv::KeyPoint, std::__ndk1::allocator<cv::KeyPoint> >, std::__ndk1::allocator<std::__ndk1::vector<cv::KeyPoint, std::__ndk1::allocator<cv::KeyPoint> > > >&)':
/xxx/ORB-SLAM2-based-AR-on-Android/app/src/main/cpp/ORB/src/ORBextractor.cc:1045: undefined reference to `cv::FAST(cv::_InputArray const&, std::__ndk1::vector<cv::KeyPoint, std::__ndk1::allocator<cv::KeyPoint> >&, int, bool)'
libORBSLAM2.a(ORBextractor.cc.o):/search/odin/gongzhenting/work/image/slam/ORB-SLAM2-based-AR-on-Android/app/src/main/cpp/ORB/src/ORBextractor.cc:1051: more undefined references to `cv::FAST(cv::_InputArray const&, std::__ndk1::vector<cv::KeyPoint, std::__ndk1::allocator<cv::KeyPoint> >&, int, bool)' follow
libORBSLAM2.a(ORBextractor.cc.o): In function `ORB_SLAM2::ORBextractor::ComputeKeyPointsOld(std::__ndk1::vector<std::__ndk1::vector<cv::KeyPoint, std::__ndk1::allocator<cv::KeyPoint> >, std::__ndk1::allocator<std::__ndk1::vector<cv::KeyPoint, std::__ndk1::allocator<cv::KeyPoint> > > >&)':
/xxx/ORB-SLAM2-based-AR-on-Android/app/src/main/cpp/ORB/src/ORBextractor.cc:1116: undefined reference to `cv::KeyPointsFilter::retainBest(std::__ndk1::vector<cv::KeyPoint, std::__ndk1::allocator<cv::KeyPoint> >&, int)'
/xxx/ORB-SLAM2-based-AR-on-Android/app/src/main/cpp/ORB/src/ORBextractor.cc:1134: undefined reference to `cv::KeyPointsFilter::retainBest(std::__ndk1::vector<cv::KeyPoint, std::__ndk1::allocator<cv::KeyPoint> >&, int)'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [out/arm64-v8a/libnative-lib.so] Error 1

my build.sh in /xxx/ORB-SLAM2-based-AR-on-Android/app/build folder is:

NDK_PATH=/yyy/android-ndk-r19c/
BUILD_PATH="arm64-v8a"

cmake \
-H".." \
-B"$BUILD_PATH" \
-DANDROID_ABI="arm64-v8a" \
-DANDROID_NDK=$NDK_PATH \
-DCMAKE_BUILD_TYPE="Release" \
-DCMAKE_TOOLCHAIN_FILE="$NDK_PATH/build/cmake/android.toolchain.cmake" \
-DANDROID_PLATFORM="android-21" \
-DANDROID_TOOLCHAIN="clang" \
-DCMAKE_C_FLAGS="-fpic -fexceptions -frtti" \
-DCMAKE_CXX_FLAGS="-fpic -fexceptions -frtti" \
-DANDROID_STL="c++_shared" \

cd arm64-v8a
make -j8 

And I have tried opencv-3.4.7-android-sdk or opencv-3.0.0-android-sdk.

How to fix the error? Can you give some advises?
Thanks

PapaMadeleine2022 avatar Sep 03 '19 11:09 PapaMadeleine2022

Hello, I'am using: ndk v16.1.4479499 cmake 3.10.2 3.2.0 which included in project to build an application and it is works.

I attach my "./app/build.gradle"(with "txt" format) and "./app/CMakeLists.txt" for pure project CMakeLists.txt

build.gradle.txt

FedorovPavel avatar Sep 03 '19 12:09 FedorovPavel

@FedorovPavel thanks for your reply. What version is the OpenCV-android-sdk you use ?

PapaMadeleine2022 avatar Sep 03 '19 13:09 PapaMadeleine2022

@IvyGongoogle 3.2.0. I tried to use 2.4.9 - on new versions android does not work. And in newer versions are missing the necessary methods or interface has changed

FedorovPavel avatar Sep 03 '19 14:09 FedorovPavel

@FedorovPavel Thanks. Now I also AS to build this project with gradle, and it works. But I would like to know how do compile the app code using cmake and make with the app/CMakeList.txt. Do you have any advises?

PapaMadeleine2022 avatar Sep 04 '19 10:09 PapaMadeleine2022

@IvyGongoogle Sorry, I can’t help with the build with cmake and make =(

FedorovPavel avatar Sep 04 '19 10:09 FedorovPavel

@FedorovPavel Thank you too.

PapaMadeleine2022 avatar Sep 04 '19 11:09 PapaMadeleine2022

@FedorovPavel Thanks. Now I also AS to build this project with gradle, and it works. But I would like to know how do compile the app code using cmake and make with the app/CMakeList.txt. Do you have any advises?

why i am not work.i am using opencv 3.2

BruceYu-Bit avatar Jul 24 '20 08:07 BruceYu-Bit

Hi @BruceYu-Bit , in case you are still interested, I addressed the compilation issues related to OpenCV 3.2.0 on my fork and submitted a pull request with all the changes: https://github.com/muziyongshixin/ORB-SLAM2-based-AR-on-Android/pull/16.

maximaging avatar Oct 08 '21 09:10 maximaging