我正在用C做一个学校的项目,我正在使用Clion作为想法。 我已经使用命令在Ubuntu中安装了ln curses
sudo apt-get install libncurses<ver>-dev
使用命令,该程序将运行! 但是我想对idee进行一些调试。 我的cmake文件是这个
cmake_minimum_required(VERSION 3.12)
project(progetto_pipe_2 C)
set(CMAKE_C_STANDARD 99)
add_executable(progetto_pipe_2 main.c movimento.c movimento.h grafica.c grafica.h area_gioco.c area_gioco.h)
如果我从idee启动应用程序,则会出现以下错误:
undefined reference to `initscr' ecc ecc
答案 0 :(得分:0)
您需要在cmake配置文件中链接库。检查这篇文章:How to link curses.h in Cmake?
尝试:
cmake_minimum_required(VERSION 3.12)
project(progetto_pipe_2 C)
set(CMAKE_C_STANDARD 99)
# Define the target
add_executable(progetto_pipe_2 main.c movimento.c movimento.h grafica.c grafica.h area_gioco.c area_gioco.h)
# Look for the package you want to link
find_package( Curses REQUIRED )
# Include the directories of the package (to find curses.h for instance)
target_include_directories(progetto_pipe_2 PRIVATE ${CURSES_INCLUDE_DIRS} )
# Link the library
target_link_libraries(progetto_pipe_2 PRIVATE ${CURSES_LIBRARIES} )