[英]Error while compiling with cmake: cannot find -ldwmapi
Edit: Im using MinGW-x86_64 on windows 编辑:我在Windows上使用MinGW-x86_64
When Im trying to compile a gtk+ 3 c project with cmake, I have this error message on the log: 当我试图用cmake编译gtk + 3 c项目时,我在日志上看到此错误消息:
"C:\Program Files\JetBrains\CLion 2017.1.3\bin\cmake\bin\cmake.exe" --build C:\Users\Jonas\ClionProjects\tutorial\cmake-build-debug --target tutorial -- -j 4
[ 50%] Linking C executable tutorial.exe
c:/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../../mingw32/bin/ld.exe: cannot find -ldwmapi
collect2.exe: error: ld returned 1 exit status
CMakeFiles\tutorial.dir\build.make:96: recipe for target 'tutorial.exe' failed
mingw32-make.exe[3]: *** [tutorial.exe] Error 1
mingw32-make.exe[2]: *** [CMakeFiles/tutorial.dir/all] Error 2
CMakeFiles\Makefile2:66: recipe for target 'CMakeFiles/tutorial.dir/all' failed
CMakeFiles\Makefile2:78: recipe for target 'CMakeFiles/tutorial.dir/rule' failed
mingw32-make.exe[1]: *** [CMakeFiles/tutorial.dir/rule] Error 2
mingw32-make.exe: *** [tutorial] Error 2
Makefile:117: recipe for target 'tutorial' failed
This is my CMakeLists.txt, in there I added gtk3 and its libraries, but when Im trying to compile, it has the errors mentioned before. 这是我的CMakeLists.txt,在其中添加了gtk3及其库,但是当我尝试编译时,它具有前面提到的错误。
cmake_minimum_required(VERSION 3.7)
project(tutorial)
set(CMAKE_C_STANDARD 99)
set(SOURCE_FILES main.c)
set(PKG_CONFIG_EXECUTABLE "C:/msys64/mingw64/bin/pkg-config.exe")
FIND_PACKAGE(PkgConfig REQUIRED)
PKG_CHECK_MODULES(GTK3 REQUIRED gtk+-3.0)
INCLUDE_DIRECTORIES(${GTK3_INCLUDE_DIRS})
LINK_DIRECTORIES(${GTK3_LIBRARY_DIRS})
add_executable(tutorial ${SOURCE_FILES})
ADD_DEFINITIONS(${GTK3_CFLAGS_OTHER})
TARGET_LINK_LIBRARIES(tutorial ${GTK3_LIBRARIES})
dwmapi.dll is provided only for Vista. dwmapi.dll仅适用于Vista。 So I guess that it is a bug of package of gtk+-3.0. 所以我想这是gtk + -3.0软件包的错误。 And -ldwmapi
is not required for your OS. 而且,您的操作系统不需要-ldwmapi
。 Below is a workaround to fix this issue. 下面是解决此问题的解决方法。 I don't make sure this will solve your issue. 我不确定这是否可以解决您的问题。 Note that this is self-responsibility. 请注意,这是自我责任。
C:\\msys64\\mingw64\\lib\\pkgconfig
在C:\\msys64\\mingw64\\lib\\pkgconfig
制作gdk-3.0.pc,gdk-broadway-3.0.pc,gdk-win32-3.0.pc的备份副本 -ldwmapi
and :wq
在vim中打开这些文件,删除-ldwmapi
和:wq
Let's create libdwmapi.a 让我们创建libdwmapi.a
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.