cmake does non link ncurses
13,307
Solution 1
For the super noob, remember target_link_libraries()
needs to be below add_executable()
:
cmake_minimum_required(VERSION 2.8) project(main)
find_package(Curses REQUIRED)
include_directories(${CURSES_INCLUDE_DIR})
add_executable(main main.cpp)
target_link_libraries(main ${CURSES_LIBRARIES})
Solution 2
before use some third party libs, you ought to find it!
in case of ncurses
you need to add find_package(Curses REQUIRED)
and then use ${CURSES_LIBRARIES}
in a call to target_link_libraries()
and target_include_directories(... ${CURSES_INCLUDE_DIR})
.
Author by
G-Mos
Updated on June 14, 2022Comments
-
G-Mos about 2 years
I am a total noob concerning cmake. My CMakeLists is really basic:
cmake_minimum_required(VERSION 2.4.6) #set the default path for built executables to the "bin" directory set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin) #set the default path for built libraries to the "lib" directory set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib) #For the Curses library to load: SET(CURSES_USE_NCURSES TRUE) include_directories( "src/" ) add_subdirectory(src)
when I make the linker does not find the ncurses commands and in the verbose mode of make I see that the compiler did not add the -lncurses. What do I have to add to the CMakeLists to make it work?
-
G-Mos over 9 yearsThank you! This worked! For complete noobs it is target_link_libraries(your_exe ${CURSES_LIBRARIES})
-
phoxd over 4 yearsI was using
Curses_INCLUDE_DIR
andCurses_LIBRARIES
once I uppercased them, it worked