lncurses on Clion with Ubuntu

lncurses on Clion with Ubuntu

我正在用 C 为学校做一个项目,我使用 Clion 作为 idee。 我已经使用命令

在 Ubuntu 中安装了 ln curses
sudo apt-get install libncurses<ver>-dev

使用 shall,程序运行正常! 但是我想用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

您需要 link 您的 cmake 配置文件中的库。检查此 post:

尝试:

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} )