在ubuntu上是否有将cmake与mqueue.h一起使用的方法
CMakeFiles/mqcreate.dir/mqcreate1.cc.o:在函数main'中: mqcreate1.cc:.text+0xa0:未定义的引用tomq_open' mqcreate1.cc:.text+0xad:mq\u close'的未定义引用在ubuntu上是否有将cmake与mqueue.h一起使用的方法,cmake,ipc,Cmake,Ipc,CMakeFiles/mqcreate.dir/mqcreate1.cc.o:在函数main'中: mqcreate1.cc:.text+0xa0:未定义的引用tomq_open' mqcreate1.cc:.text+0xad:mq\u close'的未定义引用 find_library(LIBRT rt) if(LIBRT) target_link_libraries(target_name ${LIBRT}) endif() 您需要链接到正确的库才能使用这
find_library(LIBRT rt)
if(LIBRT)
target_link_libraries(target_name ${LIBRT})
endif()
您需要链接到正确的库才能使用这些函数。请参阅Ubuntu上的man mq_open。它应该告诉你该使用哪一个。但我仍然不明白add\u compile\u options-lrt不是work@Ericlee因为它不是编译选项,而是链接期间使用的库。find_library可能有些过分,target_link_librariestarget_name rt应该足够了,因为它是一个标准的操作系统库,链接器可以自己找到。