undefined reference to `xdo_new' in clion but not in terminal
see my screencast https://www.youtube.com/watch?v=2d7CVgxHoHU&feature=youtu.be, i occurs this error in clion but not in terminal
Here is my code:
// main.cpp
extern "C" {
#include <xdo.h>
}
int main() {
xdo_t *xdo = xdo_new(NULL);
return 0;
}
# CMakeLists.txt
c make_minimum_required(VERSION 3.1)
project(try)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES main.cpp)
add_executable(try ${SOURCE_FILES})
Please sign in to leave a comment.
HI!
Could you please also attach xdo.h?
When i get xdo.h from "sudo apt-get install libxdo-dev -y", and its code is here https://github.com/jordansissel/xdotool
Not sure why it works in the terminal since you didn't link the lib.
In the cmake I don't see anywhere linking the xdo lib.
I.e.
target_link_libraries(${PROJECT_NAME} xdo)
Replace xdo with the actual library name. That should fix it. Unsure why it would work on the terminal since it shouldn't. :)
*EDIT* Watched the screen cast. The reason it works on the command line is you didn't use cmake and linked the lib with -lXDO. So yea, just add that to the cmake project and it will build just fine. The line you will need in the cmake is:
target_link_libraries(${PROJECT_NAME} XDO)
It work