1

I try to build a project based on two open source libraries. The libraries I am using are OpenCV and ceres. The libopencv_java3.so is the release OpenCV3.1.2 from the website github that include OpenCV-3.1.0-android-sdk. The libceres.so is compiled from souce code by myself.

When I build my application, NDK-build generates following information:

clang++.exe: warning: argument unused during compilation: '-nostdlib++' [-Wunused-command-line-argument]

error: undefined reference to 'cv::imwrite(cv::String const&, cv::_InputArray const&, std::__ndk1::vector > const&)'

After googling, I find one related post

Error Undefined reference to 'std::__ndk1::locale::~locale()' The answer says that different STL implementations are used.

For my case, libopencv_java.so may use gnustl_static and libceres uses c++_static. I don't understand the reason. The two implementations are both static libraries and conflict should not occur.

  1. Is all so files from opencv release compiled with gnustl_static?
  2. Why __ndk1 appears in std::vector?
  3. For one large project, different engineers take different sub-tasks. Should they link one common stl implementation? Is the requirement different for static linkage and dynamic linkage?
2
  • 2
    Say you want to pass a std::vector to both libraries which stl implementation should you use in the main project ? Feb 12, 2020 at 11:32
  • The two libraries are both linked with STL implementation as static libraries. Is this still a problem? Feb 12, 2020 at 14:34

1 Answer 1

1

This answer come late, but I hope it might help someone coming across similar problems (as I do).

Is all so files from opencv release compiled with gnustl_static?

It seems that OpenCV 3.X-android (even the latest 3.4.12 at the time of writing), uses gnustl_statc. That means all the stl components resides in namespace std. However for OpenCV 4.X-android, the library has been compiled with c++_static, so the stl components are in the namespace std::__ndk1.

Why __ndk1 appears in std::vector?

It is inline namespace.

For one large project, different engineers take different sub-tasks. Should they link one common stl implementation? Is the requirement different for static linkage and dynamic linkage?

Not sure about that...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.