Visual c++ KDevelop(Win7)下的NMake:错误LNK1104:无法打开文件';kernel32.lib';
我有一个现有的项目,我不知道如何从中创建vs解决方案。所以我决定使用KDevelop,它可以解析目录并使用Visual c++ KDevelop(Win7)下的NMake:错误LNK1104:无法打开文件';kernel32.lib';,visual-c++,cmake,linker-errors,nmake,kdevelop,Visual C++,Cmake,Linker Errors,Nmake,Kdevelop,我有一个现有的项目,我不知道如何从中创建vs解决方案。所以我决定使用KDevelop,它可以解析目录并使用CMakeLists.txt 问题是cmake找不到一些用于链接的库文件。这些文件存储的目录位于PATH中。起初,我以为我可能会为另一个拱门而编译,但我不知道从这里可以走到哪里 C:/Users/Petros/projects/QtDice/build> "C:/Program Files/CMake/bin/cmake.exe" "-DCMAKE_EXPORT_COMPILE
CMakeLists.txt
问题是cmake找不到一些用于链接的库文件。这些文件存储的目录位于PATH
中。起初,我以为我可能会为另一个拱门而编译,但我不知道从这里可以走到哪里
C:/Users/Petros/projects/QtDice/build> "C:/Program Files/CMake/bin/cmake.exe" "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON" "-DCMAKE_INSTALL_PREFIX=C:/Program Files (x86)/QtDice" "-DCMAKE_BUILD_TYPE=Debug" C:/Users/Petros/projects/QtDice
-- The CXX compiler identification is MSVC 19.15.26730.0
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.15.26726/bin/Hostx64/x64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.15.26726/bin/Hostx64/x64/cl.exe -- broken
CMake Error at C:/Program Files/CMake/share/cmake-3.12/Modules/CMakeTestCXXCompiler.cmake:45 (message):
The C++ compiler
"C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.15.26726/bin/Hostx64/x64/cl.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Users/Petros/projects/QtDice/build/CMakeFiles/CMakeTmp
Run Build Command:"nmake" "/nologo" "cmTC_c2fa6\fast"
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\bin\HostX64\x64\nmake.exe" -f CMakeFiles\cmTC_c2fa6.dir\build.make /nologo -L CMakeFiles\cmTC_c2fa6.dir\build
Building CXX object CMakeFiles/cmTC_c2fa6.dir/testCXXCompiler.cxx.obj
C:\PROGRA~2\MICROS~3\2017\COMMUN~1\VC\Tools\MSVC\1415~1.267\bin\Hostx64\x64\cl.exe @C:\Users\Petros\AppData\Local\Temp\nm8F3F.tmp
testCXXCompiler.cxx
Linking CXX executable cmTC_c2fa6.exe
"C:\Program Files\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_c2fa6.dir --manifests -- C:\PROGRA~2\MICROS~3\2017\COMMUN~1\VC\Tools\MSVC\1415~1.267\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\cmTC_c2fa6.dir\objects1.rsp @C:\Users\Petros\AppData\Local\Temp\nm9088.tmp
LINK Pass 1: command "C:\PROGRA~2\MICROS~3\2017\COMMUN~1\VC\Tools\MSVC\1415~1.267\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\cmTC_c2fa6.dir\objects1.rsp /out:cmTC_c2fa6.exe /implib:cmTC_c2fa6.lib /pdb:C:\Users\Petros\projects\QtDice\build\CMakeFiles\CMakeTmp\cmTC_c2fa6.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:CMakeFiles\cmTC_c2fa6.dir/intermediate.manifest CMakeFiles\cmTC_c2fa6.dir/manifest.res" failed (exit code 1104) with the following output:
LINK : fatal error LNK1104: cannot open file 'kernel32.lib'
NMAKE : fatal error U1077: '"C:\Program Files\CMake\bin\cmake.exe"' : return code '0xffffffff'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\bin\HostX64\x64\nmake.exe"' : return code '0x2'
Stop.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)
-- Configuring incomplete, errors occurred!
See also "C:/Users/Petros/projects/QtDice/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/Petros/projects/QtDice/build/CMakeFiles/CMakeError.log".
*** Failure: Exit code 1 ***
```
对于可能出现的问题有什么想法吗
编辑:已解决
最后我找到了一个相当老套的解决办法。VS环境中KDevelop的批处理文件不适用于VS-2017(定义了VS150COMNTOOLS
变量),但它最多支持VS-2015(VS140COMNTOOLS
)
VS2017更改了文件夹的布局,因此旧的SET script=“!base!\..\VC\vcvarsall.bat”
实际上变成了SET script=“%base%..\VC\Auxiliary\Build\vcvarsall.bat”x64
当然,这个新脚本应该在Developer命令提示符
控制台中运行,而不仅仅是单击批处理文件
setlocal EnableDelayedExpansion
setlocal enableextensions
if DEFINED VS150COMNTOOLS (
SET "base=%VS150COMNTOOLS%"
) else ( IF DEFINED VS120COMNTOOLS (
SET "base=%VS120COMNTOOLS%"
) else ( IF DEFINED VS110COMNTOOLS (
SET "base=%VS110COMNTOOLS%"
) else ( IF DEFINED VS100COMNTOOLS (
SET "base=%VS100COMNTOOLS%"
) else (
START CMD /C "The Microsoft Visual C++ compiler was not found on your system, you might not be able to compile programs. && PAUSE"
) )))
SET script="%base%..\..\VC\Auxiliary\Build\vcvarsall.bat" x64
CALL %script%
FOR /F "usebackq tokens=3*" %%A IN (`REG QUERY "HKEY_LOCAL_MACHINE\Software\KDE\KDevelop" /v Install_Dir`) DO (
set appdir=%%A %%B
)
if NOT DEFINED appdir (
FOR /F "usebackq tokens=3*" %%A IN (`REG QUERY "HKEY_LOCAL_MACHINE\Software\Wow6432Node\KDE\KDevelop" /v Install_Dir`) DO (
set appdir=%%A %%B
)
)
START "" "%appdir%\bin\kdevelop.exe"
尝试从项目的根目录中删除
build
目录,然后在VisualStudio环境中运行KDevelop(有一个链接)。是的,我就是这么做的,但运气不好。我发现cmake找不到MSVC.Yep,所以这不是KDevelop的问题。试着运行<代码> VisualStudioTo安装Eng/<代码>,确保所有的东西都是最新的,并且安装了C++组件。我认为这是一个<代码>路径>代码>问题,因为现在运行<代码> Cl<代码> > <代码开发者>命令提示>代码>给了我一个错误。谢谢:)错误0xc000007b
在我处理了混乱的路径和注销后就消失了。