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

cv_bridge STILL exposes internal GTest symbols from OpenCV and/or links incorrectly #25

Closed
cmansley opened this issue Oct 18, 2013 · 4 comments

Comments

@cmansley
Copy link

We closed issue #22 slightly preemptively. I still have this issue with just the cv_bridge package.

If we create a package as follows:

$ roscreate-pkg opencv_tests roscpp cv_bridge
$ cd opencv_tests
$ mkdir test
$ echo "rosbuild_add_gtest(test_opencv test/test_opencv.cpp)" >> CMakeLists.txt

and test_opencv.cpp contains

#include <gtest/gtest.h>

int main(int argc, char **argv)
{
  testing::InitGoogleTest(&argc, argv);

  ::testing::FLAGS_gtest_death_test_style = "threadsafe";

  return RUN_ALL_TESTS();
}

then we run make test, the test compiles, but crashes on destruction. This is because the library opencv_ts is linked incorrectly. I thought this was an opencv issue, but it seems like just a cv_bridge issue.

If we change the package by editing the manifest.xml and instead depend on image_geometry, which still depends on opencv2 the problem is not there.

Here is the comparison. With this manifest

<package>
  <description brief="opencv_tests">

     opencv_tests

  </description>
  <author>Chris Mansley</author>
  <license>BSD</license>
  <review status="unreviewed" notes=""/>
  <url>http://ros.org/wiki/opencv_tests</url>
  <depend package="roscpp"/>
  <depend package="cv_bridge"/>
</package>

and this command VERBOSE=1 make tests | grep opencv_ts. I get this line:

/usr/bin/c++   -O2 -g    -L/home/mac1pal/rdr/stacks/perception/opencv_tests/lib CMakeFiles/test_opencv.dir/test/test_opencv.cpp.o  -o ../bin/test_opencv -rdynamic -L/opt/ros/groovy/lib -L/home/mac1pal/rdr/stacks/perception/opencv_tests/lib -lroscpp -l:/usr/lib/libboost_signals-mt.so -l:/usr/lib/libboost_filesystem-mt.so -lxmlrpcpp -lcv_bridge -l:/opt/ros/groovy/lib/libopencv_calib3d.so -l:/opt/ros/groovy/lib/libopencv_contrib.so -l:/opt/ros/groovy/lib/libopencv_core.so -l:/opt/ros/groovy/lib/libopencv_features2d.so -l:/opt/ros/groovy/lib/libopencv_flann.so -l:/opt/ros/groovy/lib/libopencv_gpu.so -l:/opt/ros/groovy/lib/libopencv_highgui.so -l:/opt/ros/groovy/lib/libopencv_imgproc.so -l:/opt/ros/groovy/lib/libopencv_legacy.so -l:/opt/ros/groovy/lib/libopencv_ml.so -l:/opt/ros/groovy/lib/libopencv_nonfree.so -l:/opt/ros/groovy/lib/libopencv_objdetect.so -l:/opt/ros/groovy/lib/libopencv_photo.so -l:/opt/ros/groovy/lib/libopencv_stitching.so -l:/opt/ros/groovy/lib/libopencv_superres.so -l:/opt/ros/groovy/lib/libopencv_ts.so -l:/opt/ros/groovy/lib/libopencv_video.so -l:/opt/ros/groovy/lib/libopencv_videostab.so -lrosconsole -l:/usr/lib/libboost_regex-mt.so -l:/usr/lib/liblog4cxx.so -lroscpp_serialization -lrostime -l:/usr/lib/libboost_date_time-mt.so -l:/usr/lib/libboost_system-mt.so -l:/usr/lib/libboost_thread-mt.so -lpthread -lcpp_common ../lib/libgtest.so -lpthread -Wl,-rpath,/opt/ros/groovy/lib:/home/mac1pal/rdr/stacks/perception/opencv_tests/lib 

However, with this manifest (only changing cv_bridge to image_geometry):

<package>
  <description brief="opencv_tests">

     opencv_tests

  </description>
  <author>Chris Mansley</author>
  <license>BSD</license>
  <review status="unreviewed" notes=""/>
  <url>http://ros.org/wiki/opencv_tests</url>
  <depend package="roscpp"/>
  <depend package="image_geometry"/>
</package>

and this command VERBOSE=1 make tests | grep opencv_ts, grep fails to find opencv_ts in the link lines. But, other opencv libraries are correctly linked.

So, the story here is that it must be something in the cv_bridge package that is specifically adding the opencv_ts library. I don't know why this is happening.

@cmansley
Copy link
Author

In the /opt/ros/groovy/share/cv_bridge/cmake/cv_bridgeConfig.cmake file there is an explicit list of libraries from opencv to include, which contains opencv_ts. I don't know why cv_bridge explicitly includes the opencv libraries, when the OpenCVConfig.cmake file works correctly.

There is an explicit list of opencv libraries in the image_geometry package, but opencv_ts is missing. Hrmmm.

How is that file auto-generated?

@vrabaud
Copy link
Contributor

vrabaud commented Oct 19, 2013

Thx for reporting: the error was that opencv_ts is added if gtest has not been find_packaged before. Which was the case here as catkin was find_packaged AFTER OpenCV. Releasing now.

@cmansley
Copy link
Author

Thanks! Do you know what the process is for moving from shadow-fixed to ros-public? It would be great if I could have this bug fix in the regular Debian package.

@vrabaud
Copy link
Contributor

vrabaud commented Oct 21, 2013

Tully does that once in a while (roughly once a week) so just wait for his email on ros-users. If it's an emergency, just download the packages from here:
http://packages.ros.org/ros-shadow-fixed/ubuntu/pool/main/r/
and dpkg -i the deb.

luca-della-vedova pushed a commit to luca-della-vedova/vision_opencv that referenced this issue Sep 2, 2020
make link to control messages a real link
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants