简体   繁体   English

带有PDC的C ++ 64位项目通过Clion的CMake实现了静态链接库

[英]C++ 64bit project with PDCurses static link library via Clion's CMake

Recently I have acquired the "curses.h" and built the PDCurses "pdcurses.a" library file thanks to: https://github.com/Alexpux/MINGW-packages/tree/master/mingw-w64-pdcurses package. 最近,由于: https : //github.com/Alexpux/MINGW-packages/tree/master/mingw-w64-pdcurses软件包,我获得了“ curses.h”并构建了PDCurses的“ pdcurses.a”库文件。 I also have prepared cmake files: 我还准备了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})

Unfortunately I'm unable to link a simple "Hello World!" 不幸的是,我无法链接一个简单的“ Hello World!”。 console program because either I am getting this: 控制台程序,因为我正在得到这个:

mingw32/7.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lpdcurses collect2.exe: error: ld returned 1 exit status mingw32-make.exe[3]: * [CMakeFiles\\MatrixAlgebra.dir\\build.make:97: MatrixAlgebra.exe] Error 1 mingw32-make.exe[2]: 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] Error 2 mingw32-make.exe[1]: [CMakeFiles \\ Makefile2:67:CMakeFiles / MatrixAlgebra.dir / all]错误2 mingw32-make.exe [1]: [CMakeFiles\\Makefile2:79: CMakeFiles/MatrixAlgebra.dir/rule] Error 2 mingw32-make.exe: * [Makefile:117: MatrixAlgebra] Error 2 [CMakeFiles \\ Makefile2:79:CMakeFiles / MatrixAlgebra.dir / rule]错误2 mingw32-make.exe:* [Makefile:117:MatrixAlgebra]错误2

or this (when I change "pdcurses.a" to "libpdcurses.a"): 或这个(当我将“ pdcurses.a”更改为“ libpdcurses.a”时):

Process finished with exit code -1073741515 (0xC0000135) 流程结束,退出代码为-1073741515(0xC0000135)

I simply don't know what to do to make it proceed without problems. 我根本不知道该怎么做才能使其顺利进行。

you shouldn't treat target_link_libraries() like commandline to feed it with parameters like -Wall 您不应该像命令行一样对待target_link_libraries()来使用-Wall这样的参数

I don't know pdcurses, but when find_package finds that lib you should probably use something like: 我不知道pdcurses,但是当find_package找到该lib时,您可能应该使用类似以下内容:

target_link_libraries(MatrixAlgebra pdcurses::pdcurses)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM