I don't know how to link the curses. h and pthread. h with *.c and *.h in clion CMake. no matter how I change it, it all wrong with "undefined reference to ". I think is make by curses head file. I tried many different methods to make the cmakelist.txt, but it was always wrong. I don't know what always wrong. of course I don't know what correct method should be used.
cmake error output:
/home/laoxiao789/clion-2020.1.1/bin/cmake/linux/bin/cmake --build /home/laoxiao789/CLionProjects/as3/cmake-build-debug --target as3 -- -j 3
[ 16%] Linking C executable as3
/usr/bin/ld: CMakeFiles/as3.dir/console.c.o: in function `checkConsoleSize':
/home/laoxiao789/CLionProjects/as3/console.c:25: undefined reference to `COLS'
/usr/bin/ld: /home/laoxiao789/CLionProjects/as3/console.c:25: undefined reference to `LINES'
/usr/bin/ld: /home/laoxiao789/CLionProjects/as3/console.c:27: undefined reference to `LINES'
/usr/bin/ld: /home/laoxiao789/CLionProjects/as3/console.c:27: undefined reference to `COLS'
/usr/bin/ld: CMakeFiles/as3.dir/console.c.o: in function `consoleInit':
/home/laoxiao789/CLionProjects/as3/console.c:38: undefined reference to `initscr'
/usr/bin/ld: /home/laoxiao789/CLionProjects/as3/console.c:39: undefined reference to `cbreak'
/usr/bin/ld: /home/laoxiao789/CLionProjects/as3/console.c:40: undefined reference to `noecho'
/usr/bin/ld: /home/laoxiao789/CLionProjects/as3/console.c:41: undefined reference to `stdscr'
/usr/bin/ld: /home/laoxiao789/CLionProjects/as3/console.c:41: undefined reference to `wclear'
/usr/bin/ld: CMakeFiles/as3.dir/console.c.o: in function `consoleDrawImage':
/home/laoxiao789/CLionProjects/as3/console.c:75: undefined reference to `stdscr'
/usr/bin/ld: /home/laoxiao789/CLionProjects/as3/console.c:75: undefined reference to `wmove'
/usr/bin/ld: /home/laoxiao789/CLionProjects/as3/console.c:75: undefined reference to `stdscr'
/usr/bin/ld: /home/laoxiao789/CLionProjects/as3/console.c:75: undefined reference to `waddnstr'
/usr/bin/ld: CMakeFiles/as3.dir/console.c.o: in function `consoleClearImage':
/home/laoxiao789/CLionProjects/as3/console.c:100: undefined reference to `stdscr'
/usr/bin/ld: /home/laoxiao789/CLionProjects/as3/console.c:100: undefined reference to `wmove'
/usr/bin/ld: /home/laoxiao789/CLionProjects/as3/console.c:102: undefined reference to `stdscr'
/usr/bin/ld: /home/laoxiao789/CLionProjects/as3/console.c:102: undefined reference to `waddch'
/usr/bin/ld: CMakeFiles/as3.dir/console.c.o: in function `consoleRefresh':
/home/laoxiao789/CLionProjects/as3/console.c:110: undefined reference to `COLS'
/usr/bin/ld: /home/laoxiao789/CLionProjects/as3/console.c:110: undefined reference to `LINES'
/usr/bin/ld: /home/laoxiao789/CLionProjects/as3/console.c:110: undefined reference to `stdscr'
/usr/bin/ld: /home/laoxiao789/CLionProjects/as3/console.c:110: undefined reference to `wmove'
/usr/bin/ld: /home/laoxiao789/CLionProjects/as3/console.c:111: undefined reference to `stdscr'
/usr/bin/ld: /home/laoxiao789/CLionProjects/as3/console.c:111: undefined reference to `wrefresh'
/usr/bin/ld: CMakeFiles/as3.dir/console.c.o: in function `consoleFinish':
/home/laoxiao789/CLionProjects/as3/console.c:117: undefined reference to `endwin'
/usr/bin/ld: CMakeFiles/as3.dir/console.c.o: in function `putBanner':
/home/laoxiao789/CLionProjects/as3/console.c:127: undefined reference to `stdscr'
/usr/bin/ld: /home/laoxiao789/CLionProjects/as3/console.c:127: undefined reference to `wmove'
/usr/bin/ld: /home/laoxiao789/CLionProjects/as3/console.c:128: undefined reference to `stdscr'
/usr/bin/ld: /home/laoxiao789/CLionProjects/as3/console.c:128: undefined reference to `waddnstr'
/usr/bin/ld: CMakeFiles/as3.dir/console.c.o: in function `putString':
/home/laoxiao789/CLionProjects/as3/console.c:136: undefined reference to `stdscr'
/usr/bin/ld: /home/laoxiao789/CLionProjects/as3/console.c:136: undefined reference to `wmove'
/usr/bin/ld: /home/laoxiao789/CLionProjects/as3/console.c:137: undefined reference to `stdscr'
/usr/bin/ld: /home/laoxiao789/CLionProjects/as3/console.c:137: undefined reference to `waddnstr'
/usr/bin/ld: CMakeFiles/as3.dir/console.c.o: in function `finalKeypress':
/home/laoxiao789/CLionProjects/as3/console.c:174: undefined reference to `flushinp'
/usr/bin/ld: /home/laoxiao789/CLionProjects/as3/console.c:176: undefined reference to `COLS'
/usr/bin/ld: /home/laoxiao789/CLionProjects/as3/console.c:176: undefined reference to `LINES'
/usr/bin/ld: /home/laoxiao789/CLionProjects/as3/console.c:176: undefined reference to `stdscr'
/usr/bin/ld: /home/laoxiao789/CLionProjects/as3/console.c:176: undefined reference to `wmove'
/usr/bin/ld: /home/laoxiao789/CLionProjects/as3/console.c:177: undefined reference to `stdscr'
/usr/bin/ld: /home/laoxiao789/CLionProjects/as3/console.c:177: undefined reference to `wgetch'
collect2: error: ld returned 1 exit status
make[3]: *** [CMakeFiles/as3.dir/build.make:164: as3] Error 1
make[2]: *** [CMakeFiles/Makefile2:96: CMakeFiles/as3.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:103: CMakeFiles/as3.dir/rule] Error 2
make: *** [Makefile:138: as3] Error 2
my CMake file :
cmake_minimum_required(VERSION 3.17)
project(as3 C)
set(CMAKE_C_STANDARD 99)
find_package(Curses REQUIRED)
include_directories(${CURSES_INCLUDE_DIR})
add_executable(as3 centipede.c centipede.h console.c console.h main.c player.c player.h threadwrappers.c threadwrappers.h)
target_link_libraries(as3 ${CURSES_LIBRARIES})
set_target_properties(as3 PROPERTIES LINK_LIBRARIES -lpthread)