我在CLion中为我的项目添加一个外部库时遇到了一些问题,我发现的关于这个主题的所有内容并没有让我更进一步。
我添加了这些文件:
include/curses.h
include/panel.h
lib/pdcurses.lib
cmake-build-debug/pdcurses.dll
我还将文件添加到我的MinGW文件夹,以防有人在那里看...是的,我迷路了。
我的CMakeLists.txt如何查找?尝试了这么多,但因为我真的不知道cmake我无法让它工作。
目前它看起来像这样
cmake_minimum_required(VERSION 3.6)
project(113_curses)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lpdcurses")
set(SOURCE_FILES main.cpp)
add_executable(113_curses ${SOURCE_FILES})
include_directories(${MY_SOURCE_DIR}/include)
link_directories(${MY_SOURCE_DIR}/lib)
target_link_libraries(113_curses pdcurses.lib)
错误
[ 50%] Linking CXX executable 113_curses.exe
C:/Tools/mingw-w64/x86_64-6.3.0-win32-seh-rt_v5-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Tools/mingw-w64/x86_64-6.3.0-win32-seh-rt_v5-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../lib/pdcurses.lib when searching for -lpdcurses
C:/Tools/mingw-w64/x86_64-6.3.0-win32-seh-rt_v5-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Tools/mingw-w64/x86_64-6.3.0-win32-seh-rt_v5-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../pdcurses.lib when searching for -lpdcurses
C:/Tools/mingw-w64/x86_64-6.3.0-win32-seh-rt_v5-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Tools/mingw-w64/x86_64-6.3.0-win32-seh-rt_v5-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../lib/pdcurses.lib when searching for -lpdcurses
C:/Tools/mingw-w64/x86_64-6.3.0-win32-seh-rt_v5-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Tools/mingw-w64/x86_64-6.3.0-win32-seh-rt_v5-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../lib\pdcurses.lib when searching for -lpdcurses
C:/Tools/mingw-w64/x86_64-6.3.0-win32-seh-rt_v5-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Tools/mingw-w64/x86_64-6.3.0-win32-seh-rt_v5-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../pdcurses.lib when searching for -lpdcurses
C:/Tools/mingw-w64/x86_64-6.3.0-win32-seh-rt_v5-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Tools/mingw-w64/x86_64-6.3.0-win32-seh-rt_v5-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../..\pdcurses.lib when searching for -lpdcurses
C:/Tools/mingw-w64/x86_64-6.3.0-win32-seh-rt_v5-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lpdcurses
C:/Tools/mingw-w64/x86_64-6.3.0-win32-seh-rt_v5-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Tools/mingw-w64/x86_64-6.3.0-win32-seh-rt_v5-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../lib/pdcurses.lib when searching for -lpdcurses
C:/Tools/mingw-w64/x86_64-6.3.0-win32-seh-rt_v5-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Tools/mingw-w64/x86_64-6.3.0-win32-seh-rt_v5-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../pdcurses.lib when searching for -lpdcurses
C:/Tools/mingw-w64/x86_64-6.3.0-win32-seh-rt_v5-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Tools/mingw-w64/x86_64-6.3.0-win32-seh-rt_v5-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../lib/pdcurses.lib when searching for -lpdcurses
C:/Tools/mingw-w64/x86_64-6.3.0-win32-seh-rt_v5-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Tools/mingw-w64/x86_64-6.3.0-win32-seh-rt_v5-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../lib\pdcurses.lib when searching for -lpdcurses
C:/Tools/mingw-w64/x86_64-6.3.0-win32-seh-rt_v5-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Tools/mingw-w64/x86_64-6.3.0-win32-seh-rt_v5-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../pdcurses.lib when searching for -lpdcurses
C:/Tools/mingw-w64/x86_64-6.3.0-win32-seh-rt_v5-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Tools/mingw-w64/x86_64-6.3.0-win32-seh-rt_v5-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../..\pdcurses.lib when searching for -lpdcurses
C:/Tools/mingw-w64/x86_64-6.3.0-win32-seh-rt_v5-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lpdcurses
collect2.exe: error: ld returned 1 exit status
CMakeFiles\113_curses.dir\build.make:96: recipe for target '113_curses.exe' failed
CMakeFiles\Makefile2:66: recipe for target 'CMakeFiles/113_curses.dir/all' failed
mingw32-make.exe[2]: *** [113_curses.exe] Error 1
Makefile:82: recipe for target 'all' failed
mingw32-make.exe[1]: *** [CMakeFiles/113_curses.dir/all] Error 2
mingw32-make.exe: *** [all] Error 2
答案 0 :(得分:0)
您需要添加:
include_directories(/path/to/curses/include)