0
# compiler is q++:
set(CMAKE_CXX_COMPILER q++)

set(CMAKE_CXX_FLAGS "-I/usr/include/")

# linking as below
add_executable(MYPGM main.cpp)
target_link_libraries(MYPGM  socket) # -> this links fine, if I link same way libtest, not even identifying the library from the path

target_link_libraries(MYPGM -L"/usr/lib/libtest.so")

On linux it links fine. On QNX it finds the path but it says undefined reference

main.cpp.o: in function `main':
main.cpp:(.text+0xdc): undefined reference to `testinit'
Tsyvarev
  • 60,011
  • 17
  • 110
  • 153
bibhuti
  • 1
  • 1
  • Linker flag `-L` specifies a **directory** for search libraries. You definitely don't want to use it with the library **file**. Correct: `target_link_libraries(MYPGM "/usr/lib/libtest.so")`. – Tsyvarev Sep 07 '22 at 08:54

0 Answers0