使用 cmake 静态链接 ncurses 库

问题描述

我是 cmake 的菜鸟,但我想将 ncurses 静态链接到我的程序,这样我就可以在没有安装任何正确软件包的计算机上运行我的程序(无需设置)。

该程序名为 wordgame,我正在链接其他一些 c 文件(如 color_init)。包含目录包含我所有的头文件

这是目前我的 CMakeLists.txt:

cmake_minimum_required(VERSION 3.17)
project(wordgame C)

set(CMAKE_C_STANDARD 99)
add_compile_options(-g -Wall -Wextra -pedantic)

set(INCLUDE_DIR include)
include_directories (${INCLUDE_DIR})     

find_package(Curses required)
include_directories(${CURSES_INCLUDE_DIR})
add_executable(wordgame main.c color_init.c)
target_link_libraries(${PROJECT_NAME} ${CURSES_LIBRARIES})

target_link_libraries 似乎动态链接 ncurses,因为我收到以下错误

./wordgame: error while loading shared libraries: libncursesw.so.6: cannot open shared object file: No such file or directory

那么如何使用 cmake 将 ncurses 静态链接到我的程序?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)