Clion adding -lrt in cmake
已回答
Hi there,
I am having a problem with adding mqueue.h in my project. On a compiler time it gives me an error: undefined reference to `mq_open'. However, my cmake file already contains -lrt option:
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -lrt")
What's wrong with it or what else I have to do?
Thanks
请先登录再写评论。
Hi! In order to link to the rt library, you need to add something similar to the following to your CMakeLists.txt:
where target_name should be replaced with your target name.
Please also read our quick CMake tutorial: https://www.jetbrains.com/help/clion/quick-cmake-tutorial.html#libs
It works, thanks!