NMake under KDevelop (Win7) : error LNK1104: cannot open file 'kernel32.lib'

0

I have an existing project that I didn't know how to create a vs solution from it. So I decided to use KDevelop which can parse the directory and use the CMakeLists.txt.

The thing is that cmake can't find some lib files for the linking. The directory that these files are stored is in PATH. At first I thought that I might be compiling for another ARCH but I don't know where to go from here.

    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 ***
```

Are there any ideas on what could be wrong?

EDIT : SOLVED

At last I found a rather hackish workaround. The batch file for KDevelop in VS enviroment, doesn't work for VS-2017 (which defined the VS150COMNTOOLS variable) but it supports up to VS-2015 (VS140COMNTOOLS).

VS2017 changed the layout of it's folders so the old SET script="!base!\..\..\VC\vcvarsall.bat" really becomes SET script="%base%..\..\VC\Auxiliary\Build\vcvarsall.bat" x64.

Of course this new script should be run inside Developer Command Prompt console and not by just clicking the batch file.

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"
visual-c++
cmake
linker-errors
nmake
kdevelop
asked on Stack Overflow Sep 29, 2018 by Petross404 • edited Oct 1, 2018 by Petross404

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0