简体   繁体   中英

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. I also have prepared cmake files:

# 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!" 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]: [CMakeFiles\\Makefile2:67: CMakeFiles/MatrixAlgebra.dir/all] Error 2 mingw32-make.exe[1]: [CMakeFiles\\Makefile2:79: CMakeFiles/MatrixAlgebra.dir/rule] Error 2 mingw32-make.exe: * [Makefile:117: MatrixAlgebra] Error 2

or this (when I change "pdcurses.a" to "libpdcurses.a"):

Process finished with exit code -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

I don't know pdcurses, but when find_package finds that lib you should probably use something like:

target_link_libraries(MatrixAlgebra pdcurses::pdcurses)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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