Undefined reference to `shm_open 'using CMake
I am using CMake under Ubuntu 14.04 to set up my project. I need to use a third party library (say stuff.so). In CMakeLists.txt, I am using TARGET_LINK_LIBRARIES to link the material library. However, I got an error:
DIR_TO_LIB / stuff.so: -1: error: undefined reference to `shm_open '
I tried to put this flag in CMakeLists.txt but it didn't work:
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lrt")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lrt")
A post ( link ) that says -lrt should be placed as the last argument to g ++. In my case, when using CMake, how should I do this?
UPDATE : I added
SET (CMAKE_VERBOSE_MAKEFILE 1)
and I found that -lrt is not the last one (even though I put it at the end of the target link). See link for compilation.
As you can see from the compilation output, there are several bind flags for opencv. I don't understand how this could happen when I link the OpenCV library first in TARGET_LINK_LIBRARIES. How does CMake handle this binding order?
Also see my CMakeLists.txt .
Thank.
source to share