我正在构建一个需要使用ncurses库的学校项目应用程序。在尝试使用mvwaddwstr()
函数时,出现以下错误:undefined reference to `mvwaddwstr'
。
我的CMake配置文件如下:
cmake_minimum_required(VERSION 3.0)
set(CMAKE_C_STANDARD 11)
project(client)
# Libraries
find_package(Curses REQUIRED)
find_package(Threads REQUIRED)
include_directories(${CURSES_INCLUDE_DIRS})
# Sources
set(CLIENT_SOURCE_FILES
main.c)
# Links
add_library(client_library ${CLIENT_SOURCE_FILES})
add_executable(client ${CLIENT_SOURCE_FILES})
target_link_libraries(client ${CURSES_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
target_include_directories(client INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>")
修改
根据建议我尝试添加:
set(CURSES_NEED_NCURSES TRUE)
set(CURSES_NEED_WIDE TRUE)
include(FindCurses)
在find_package
行之前,但它仍无法正常工作。