C ++ 64位项目,通过Clion的CMake使用PDCurses静态链接库

时间:2018-06-13 17:31:40

标签: c++ cmake 64-bit clion pdcurses

最近我收到了" curses.h"并建立了PDCurses" pdcurses.a"库文件感谢: https://github.com/Alexpux/MINGW-packages/tree/master/mingw-w64-pdcurses 包。我也准备了cmake文件:

# pdcurses-config.cmake
set(PDCURSES_LIBDIR "${PROJECT_SOURCE_DIR}/lib")
set(PDCURSES_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/src/include")
set(PDCURSES_LIBRARIES "-L${PDCURSES_LIBDIR} -lpdcurses -static -Wall -Werror")
string(STRIP "${PDCURSES_LIBRARIES}" PDCURSES_LIBRARIES)



# CMakeLists.txt
cmake_minimum_required(VERSION 3.10)
project(MatrixAlgebra)

set(CMAKE_CXX_STANDARD 11)

set(PDCURSES_DIR "${PROJECT_SOURCE_DIR}/cmake")
find_package(PDCURSES REQUIRED)
include_directories(${PDCURSES_INCLUDE_DIRS})


set(SOURCE_FILES src/main.cpp)
add_executable(MatrixAlgebra ${SOURCE_FILES})
target_link_libraries(MatrixAlgebra ${PDCURSES_LIBRARIES})

不幸的是,我无法链接一个简单的" Hello World!"控制台程序,因为我得到了这个:

  

mingw32 / 7.3.0 /../../../../ x86_64-w64-mingw32 / bin / ld.exe:找不到-lpdcurses   collect2.exe:错误:ld返回1退出状态   mingw32-make.exe [3]: * [CMakeFiles \ MatrixAlgebra.dir \ build.make:97:MatrixAlgebra.exe]错误1   mingw32-make.exe [2]: [CMakeFiles \ Makefile2:67:CMakeFiles / MatrixAlgebra.dir / all]错误2   mingw32-make.exe [1]: [CMakeFiles \ Makefile2:79:CMakeFiles / MatrixAlgebra.dir / rule]错误2   mingw32-make.exe:* [Makefile:117:MatrixAlgebra]错误2

或者这(当我改变" pdcurses.a"到" libpdcurses.a")时:

  

处理完成,退出代码为-1073741515(0xC0000135)

我根本不知道该怎么做才能让它顺利进行。

1 个答案:

答案 0 :(得分:0)

你不应该像命令行那样对target_link_libraries()进行处理,以便使用-Wall

这样的参数来提供它

我不知道pdcurses,但是当find_package找到lib时你应该使用类似的东西:

target_link_libraries(MatrixAlgebra pdcurses::pdcurses)