Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot build shared libs in android due to undefined references in sample hello-android #7590

Closed
btut opened this issue Oct 31, 2016 · 3 comments · Fixed by #7678
Closed

Comments

@btut
Copy link

btut commented Oct 31, 2016

System information (version)
  • OpenCV => commit 4c66772
  • Operating System / Platform => macOS Sierra 10.12.1 / 64 Bit
  • Compiler => Android NDK r13 (using g++ 4.9)
Detailed description

Cannot build OpenCV shared libraries for android due to undefined references in hello-android/main.cpp. Build works fine if I just set the main method in hello-android/main.cpp to do nothing and return 0.

CMakeFiles/hello-android.dir/hello-android/main.cpp.o:main.cpp:function main: error: undefined reference to 'cv::getTextSize(cv::String const&, int, double, int, int*)'
CMakeFiles/hello-android.dir/hello-android/main.cpp.o:main.cpp:function main: error: undefined reference to 'cv::putText(cv::InputOutputArray const&, cv::String const&, cv::Point, int, double, cv::Scalar_, int, int, bool)'
collect2: error: ld returned 1 exit status
make[3]: *** [bin/hello-android] Error 1
make[2]: *** [samples/android/CMakeFiles/hello-android.dir/all] Error 2

Steps to reproduce

build with the following commands:

cd OpenCV/platforms; \

mkdir -p build_android_arm; \

cd build_android_arm; \

cmake -DBUILD_SHARED_LIBS=ON -DANDROID_NATIVE_API_LEVEL=21 -DBUILD_EXAMPLES=OFF -DBUILD_DOCS=OFF -DBUILD_opencv_xfeatures2d=OFF -DWITH_CUDA=OFF -DWITH_OPENCL=ON -DOPENCV_EXTRA_MODULES_PATH=../../../OpenCVContrib/modules -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON -DCMAKE_TOOLCHAIN_FILE=../android/android.toolchain.cmake $@ ../.. && \

make -j12
@alalek
Copy link
Member

alalek commented Oct 31, 2016

@btut
Copy link
Author

btut commented Oct 31, 2016

I cannot confirm. I just tried with ndk r10e and it failed as well. I am unable to read from the buildbot if DBUILD_SHARED_LIBS is set, because I only get this error when building the shared libs, static libs work fine.

@dec1
Copy link
Contributor

dec1 commented Nov 15, 2016

I confirm that I can reproduce this problem.

cd platforms
export PATH=/home/declan/Documents/zone/mid/bin/android/google/sdk/cmake/3.6.3155560/bin:$PATH
export ANDROID_NDK=/home/declan/Documents/zone/mid/bin/android/google/sdk/ndk-bundle

scripts/cmake_android_arm.sh  -DBUILD_SHARED_LIBS=ON -DANDROID_NATIVE_API_LEVEL=9 -DANDROID_STL=gnustl_shared

cd build_android_arm
make -j8

[ 60%] Built target opencv_superres /home/declan/Documents/zone/mid/bin/android/opencv/opencv_github_fork_dec1/samples/android/hello-android/main.cpp:16: error: undefined reference to 'cv::getTextSize(cv::String const&, int, double, int, int*)' /home/declan/Documents/zone/mid/bin/android/opencv/opencv_github_fork_dec1/samples/android/hello-android/main.cpp:18: error: undefined reference to 'cv::putText(cv::_InputOutputArray const&, cv::String const&, cv::Point_<int>, int, double, cv::Scalar_<double>, int, int, bool)' collect2: error: ld returned 1 exit status

Ive created a pull request that would resolve this:

#7678

samples/android/hello-android is not being linked to libopencv_imgproc.so

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants