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?
Scheff's Cat
  • 19,528
  • 6
  • 28
  • 56
Jogging Song
  • 573
  • 6
  • 28

1 Answers1

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...

zhouch
  • 45
  • 6