CMake linking Windows SDK
CMake linking Windows SDK
我在CLion中有一个项目,我需要在其中包含Windows 8.1 SDK中的库,所以我尝试使用CMake来链接它。
我没有任何 .so 或 .dll,而是 .lib(或直接使用 .h 文件(。
具体来说,这个库是dsound.h。
我试图寻找相关问题,但我找到的解决方案都不适合我:我该怎么做?
我目前的CMakeList.txt是
cmake_minimum_required(VERSION 3.7)
project(Project)
set(CMAKE_CXX_STANDARD 11)
include_directories(${WinSDK})
set(SOURCE_FILES main.cpp file1.h file1.cpp)
add_executable(Project ${SOURCE_FILES})
target_link_libraries(Project ${WinSDK})
其中 WinSDK 是包含 Windows SDK 位置的变量。
我得到的错误如下:
[ 33%] Building CXX object CMakeFiles/Project.dir/main.cpp.obj
[ 66%] Building CXX object CMakeFiles/Project.dir/soundclass.cpp.obj
In file included from C:projectPathsoundclass.cpp:4:0:
C:projectPathsoundclass.h:21:24: fatal error: dsound.h: No such file or directory
In file included from C:projectPathmain.cpp:5:0:
C:projectPathsoundclass.h:21:24: fatal error: dsound.h: No such file or directory
compilation terminated.
compilation terminated.
CMakeFilesProject.dirbuild.make:61: recipe for target 'CMakeFiles/Project.dir/main.cpp.obj' failed
CMakeFilesProject.dirbuild.make:85: recipe for target 'CMakeFiles/Project.dir/soundclass.cpp.obj' failed
CMakeFilesMakefile2:66: recipe for target 'CMakeFiles/Project.dir/all' failed
mingw32-make.exe[3]: *** [CMakeFiles/Project.dir/main.cpp.obj] Error 1
mingw32-make.exe[3]: *** Waiting for unfinished jobs....
mingw32-make.exe[3]: *** [CMakeFiles/Project.dir/soundclass.cpp.obj] Error 1
mingw32-make.exe[2]: *** [CMakeFiles/Project.dir/all] Error 2
CMakeFilesMakefile2:78: recipe for target 'CMakeFiles/Project.dir/rule' failed
Makefile:117: recipe for target 'Project' failed
mingw32-make.exe[1]: *** [CMakeFiles/Project.dir/rule] Error 2
mingw32-make.exe: *** [Project] Error 2
无法正确设置${WinSDK}
,因为您对包含和库使用相同的变量。
其他提示:
- CMAKE_CXX_STANDARD对 MSVC 编译器没有任何作用 使用
target_include_directories()
比使用include_directories()
更好,以保持目标信息更清晰
相关文章:
- 升级到 Windows 10 版本 1809 SDK 后,我无法编译使用 C++/WinRT 的项目
- "byte":使用Crypto++和Windows SDK时出现不明确的符号错误
- C++/WinRT,Windows SDK 17134的一部分与Visual Studio 15.8 Preview 3
- 如何在Windows Media Foundation SDK中指定语言列表对象
- CMAKE:查找/添加Visual Studio或Windows SDK库和标头的正确方法?
- CMake linking Windows SDK
- 我需要哪个SDK确保Windows 7在Visual Studio C 2017中的兼容性
- Windows SDK 控制可用的函数
- 当 Windows SDK 版本设置为 15063.13 时"LNK1104 Cannot open file 'kernel32.lib' "
- Visual Studio 2017中的Windows SDK版本设置
- 如何通过 Windows SDK 以编程方式访问"netsh"API
- DirectX 11 调试器需要 Windows SDK 10,但它在 IDE 中处于选中状态并存在于系统中
- 无法使用Yocto生成适用于Windows的SDK
- Windows SDK 8:关于安装位置,文件夹命名法和Windowssdkdir_old Env变量的混乱
- 哪个Windows SDK最适合我C++Win32
- 致命错误 C1189:#error:Windows SDK 版本错误
- OpenGL重新定义错误与Windows SDK文件相冲突时
- 在Windows Intellij Idea中配置C SDK
- 适用于Windows应用商店的Facebook SDK
- windows sdk 7.1 64位构建的CloseHandle显然不在kernel32.lib中