Open itspalomo opened 1 year ago
Oof linker errors, never fun to debug. First thing I would sanity check here is if this is really the shared library not being found. Just delete it and see if the error changes. I think the library is being found otherwise you'd see find_package complaining not the linker.
Also if you go to the directory containing libseek.so and run objdump -T libseek.so | grep _ZN7LibSeek11SeekThermalD5Ev
should show you if that function exists in the library. I'm pretty sure it doesn't.
The example programs are statically linking. So I suggest to get you moving again trying that while I figure out the virtual function issues which seem to be happening here ( haven't touched c++ in a couple of years and need to reimport some knowledge ).
So I tried using find_library with accompanying target_linked_libraries instead of find_package
and that worked. The issue seems to be that once the library is installed, it doesn't generate the CMAKE_MODULE_PATH
variables which should be in the /usr/local/lib/cmake/[libname].cmake
directory. Though, I am unsure as to how to do that, is there a way to just export it so find_package
is able to find it? Here is the CMAKE working file:
cmake_minimum_required(VERSION 3.5)
project(imaging)
# Default to C99
if(NOT CMAKE_C_STANDARD)
set(CMAKE_C_STANDARD 99)
endif()
# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
find_library(seeklib seek NAME libseek libseek-thermal lseek DOC "seek library" REQUIRED )
# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(OpenCV 4.2.0 REQUIRED)
find_package(cv_bridge REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(std_msgs REQUIRED)
find_package(image_transport REQUIRED)
add_executable(image_pub src/image_pub.cpp)
target_link_libraries(image_pub ${seeklib})
target_include_directories(image_pub PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
ament_target_dependencies(
image_pub
"rclcpp"
"image_transport"
"cv_bridge"
"sensor_msgs"
"std_msgs"
"OpenCV"
)
install(TARGETS image_pub
DESTINATION lib/${PROJECT_NAME})
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
# the following line skips the linter which checks for copyrights
# uncomment the line when a copyright and license is not present in all source files
#set(ament_cmake_copyright_FOUND TRUE)
# the following line skips cpplint (only works in a git repo)
# uncomment the line when this package is not in a git repo
#set(ament_cmake_cpplint_FOUND TRUE)
ament_lint_auto_find_test_dependencies()
endif()
ament_package()
Though I find it interesting that it didn't need the path for the include directories but linked directories it did.
Also if you go to the directory containing libseek.so and run
objdump -T libseek.so | grep _ZN7LibSeek11SeekThermalD5Ev
should show you if that function exists in the library. I'm pretty sure it doesn't. The example programs are statically linking. So I suggest to get you moving again trying that while I figure out the virtual function issues which seem to be happening here ( haven't touched c++ in a couple of years and need to reimport some knowledge ).
also, running this command did not produce an output.
ubuntu@ubuntu:/usr/local/lib$ ls
cmake libopencv_features2d.so libopencv_highgui.so.406 libopencv_ml.so.4.6.0 libopencv_videoio.so
libopencv_calib3d.so libopencv_features2d.so.406 libopencv_highgui.so.4.6.0 libopencv_objdetect.so libopencv_videoio.so.406
libopencv_calib3d.so.406 libopencv_features2d.so.4.6.0 libopencv_imgcodecs.so libopencv_objdetect.so.406 libopencv_videoio.so.4.6.0
libopencv_calib3d.so.4.6.0 libopencv_flann.so libopencv_imgcodecs.so.406 libopencv_objdetect.so.4.6.0 libopencv_video.so
libopencv_core.so libopencv_flann.so.406 libopencv_imgcodecs.so.4.6.0 libopencv_photo.so libopencv_video.so.406
libopencv_core.so.406 libopencv_flann.so.4.6.0 libopencv_imgproc.so libopencv_photo.so.406 libopencv_video.so.4.6.0
libopencv_core.so.4.6.0 libopencv_gapi.so libopencv_imgproc.so.406 libopencv_photo.so.4.6.0 libseek.so
libopencv_dnn.so libopencv_gapi.so.406 libopencv_imgproc.so.4.6.0 libopencv_stitching.so libuvc.so
libopencv_dnn.so.406 libopencv_gapi.so.4.6.0 libopencv_ml.so libopencv_stitching.so.406 python2.7
libopencv_dnn.so.4.6.0 libopencv_highgui.so libopencv_ml.so.406 libopencv_stitching.so.4.6.0 python3.8
ubuntu@ubuntu:/usr/local/lib$ objdump -T libseek.so | grep _ZN7LibSeek11SeekThermalD5Ev
ubuntu@ubuntu:/usr/local/lib$
System Information
OpenCV python version: 4.2.0 && 4.6.0 Operating System: Ubuntu Server 20.04 Platform: Raspberry Pi 4b Firmware: Nov 18 2021 16:17:39 version: d9b293558b4cef6aabedcc53c178e7604de90788 (clean) (release) (start_x) Python version: 3.8.10
Detailed description
Hello, I am using ROS to configure the libseek-thermal compact pro on a drone to publish the feed so it's usable by multiple programs. This is for my university capstone project, please forgive me if it is a silly error I am not catching. I am running into an issue where I continue to get
undefined reference
errors in the following code:More specifically, I get the following issues:
I suspect this to be a CMAKE issue but am unsure what I am doing wrong... ROS uses amentcmake, and here is the
CMakeLists.txt
Running
sudo make install
again reinstalls the library as expected in the/usr/local/...
directory. Is there a way to tell CMAKE to include them?Note: testing commands via CLI as described in the readme work as expected.