我正在用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
最佳答案
您需要在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} )
关于c++ - 使用Ubuntu吸引Clion,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/54324634/