I'd like to use OpenCV's interactive calibration tool with GigE camera but I'm running into compile errors:
/usr/bin/ld: /home/move/Downloads/PV_API/lib-pc/x64/4.7/libPvAPI.a(PvTimer.o): in function `cPvTimer::Arm(unsigned int)':
PvTimer.cpp:(.text+0x3bc): undefined reference to `timer_settime'
/usr/bin/ld: /home/move/Downloads/PV_API/lib-pc/x64/4.7/libPvAPI.a(PvTimer.o): in function `cPvTimer::Disarm()':
PvTimer.cpp:(.text+0x429): undefined reference to `timer_settime'
/usr/bin/ld: /home/move/Downloads/PV_API/lib-pc/x64/4.7/libPvAPI.a(PvTimer.o): in function `cPvTimer::~cPvTimer()':
PvTimer.cpp:(.text+0x69c): undefined reference to `timer_delete'
/usr/bin/ld: /home/move/Downloads/PV_API/lib-pc/x64/4.7/libPvAPI.a(PvTimer.o): in function `cPvTimer::cPvTimer(unsigned int)':
PvTimer.cpp:(.text+0x8ad): undefined reference to `timer_create'
/usr/bin/ld: /home/move/Downloads/PV_API/lib-pc/x64/4.7/libPvAPI.a(PvTimer.o): in function `cPvTimer::cPvTimer()':
PvTimer.cpp:(.text+0xacd): undefined reference to `timer_create'
collect2: error: ld returned 1 exit status
make[2]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/build.make:293: lib/libopencv_videoio.so.4.6.0] Error 1
make[1]: *** [CMakeFiles/Makefile2:1898: modules/videoio/CMakeFiles/opencv_videoio.dir/all] Error 2
make: *** [Makefile:163: all] Error 2
I am aware that PV_API is deprecated. I downloaded the legacy PV_API from the Allied Vision website. Due to limited time I'd like to avoid interfacing with the camera's SDK directly if I can. (I did found these relevant answers [1], [2] that recommend not doing what I'm trying to do).
My hunch is that if I can pass -lrt
to opencv_videoio
's library I might get away with it .
I did try this using CMAKE_CXX_FLAGS
and add_link_options()
, but no joy.
For reference here's the diff of my attempt:
diff --git a/modules/videoio/CMakeLists.txt b/modules/videoio/CMakeLists.txt
index 377029f45f..dffdfbe7c8 100644
--- a/modules/videoio/CMakeLists.txt
+++ b/modules/videoio/CMakeLists.txt
@@ -260,6 +260,9 @@ if(VIDEOIO_ENABLE_PLUGINS)
ocv_target_compile_definitions(${the_module} PRIVATE ENABLE_PLUGINS)
endif()
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lrt")
+# add_link_options("-lrt")
+
ocv_target_link_libraries(${the_module} LINK_PRIVATE ${tgts})
# copy FFmpeg dll to the output folder
diff --git a/modules/videoio/cmake/detect_pvapi.cmake b/modules/videoio/cmake/detect_pvapi.cmake
index f2c6d4bcea..038db96c0e 100644
--- a/modules/videoio/cmake/detect_pvapi.cmake
+++ b/modules/videoio/cmake/detect_pvapi.cmake
@@ -17,5 +17,7 @@ if(NOT HAVE_PVAPI)
endif()
if(HAVE_PVAPI)
+ # add_link_options("-lrt")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lrt")
ocv_add_external_target(pvapi "${PVAPI_INCLUDE}" "${PVAPI_LIBRARY}" "HAVE_PVAPI")
endif()
Maybe I'm not using the CMake magic or I'm doing it in the wrong place?
Has anyone ran into this recently? What's the simplest way to get OpenCV apps to build with GigE support on Ubuntu?