Linking error


Hello,

I have been trying to build my gui with cmake for some time now but i always end up with a linking error. I have been trying some different things but i can’t get it to create the missing .lib file

C:\\Projects\\tmp>cmake -S C:/Projects/tmp -B C:/Projects/tmp/build -G Ninja -DCMAKE_BUILD_TYPE=Release
– The CXX compiler identification is MSVC 19.38.33145.0
– Detecting CXX compiler ABI info
– Detecting CXX compiler ABI info - done
– Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/18/BuildTools/VC/Tools/MSVC/14.38.33130/bin/Hostx64/x64/cl.exe - skipped
– Detecting CXX compile features
– Detecting CXX compile features - done
– Configuring done (1.8s)
– Generating done (0.0s)
– Build files have been written to: C:/Projects/tmp/build
C:\\Projects\\tmp>cmake --build C:/Projects/tmp/build --target gui
\[7/7\] Linking CXX executable gui.exe
FAILED: \[code=4294967295\] gui.exe
C:\\WINDOWS\\system32\\cmd.exe /C “cd . && “C:\\Program Files\\CMake\\bin\\cmake.exe” -E vs_link_exe --msvc-ver=1938 --intdir=CMakeFiles\\gui.dir --rc=C:\\PROGRA\~2\\WI3CF2\~1\\10\\bin\\100261\~1.0\\x64\\rc.exe --mt=C:\\PROGRA\~2\\WI3CF2\~1\\10\\bin\\100261\~1.0\\x64\\mt.exe --manifests  – C:\\PROGRA\~2\\MICROS\~2\\18\\BUILDT\~1\\VC\\Tools\\MSVC\\1438\~1.331\\bin\\Hostx64\\x64\\link.exe /nologo CMakeFiles\\gui.dir\\main.cpp.obj CMakeFiles\\gui.dir\\gui.cpp.obj CMakeFiles\\gui.dir\\catalog_reader.cpp.obj  /out:gui.exe /implib:gui.lib /pdb:gui.pdb /version:0.0 -machine:x64 /INCREMENTAL:NO /subsystem:console -LIBPATH:C:\\root_src\\build\\lib Dict.lib  C:\\root_src\\build\\lib\\libGui.lib  C:\\root_src\\build\\lib\\libGpad.lib  C:\\root_src\\build\\lib\\libGraf.lib  C:\\root_src\\build\\lib\\libHist.lib  C:\\root_src\\build\\lib\\libMatrix.lib  C:\\root_src\\build\\lib\\libRIO.lib  C:\\root_src\\build\\lib\\libMathCore.lib  C:\\root_src\\build\\lib\\libImt.lib  C:\\root_src\\build\\lib\\libThread.lib  C:\\root_src\\build\\lib\\libCore.lib  C:\\vcpkg\\installed\\x64-windows\\lib\\jsoncpp.lib  kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd .”
LINK: command “C:\\PROGRA\~2\\MICROS\~2\\18\\BUILDT\~1\\VC\\Tools\\MSVC\\1438\~1.331\\bin\\Hostx64\\x64\\link.exe /nologo CMakeFiles\\gui.dir\\main.cpp.obj CMakeFiles\\gui.dir\\gui.cpp.obj CMakeFiles\\gui.dir\\catalog_reader.cpp.obj /out:gui.exe /implib:gui.lib /pdb:gui.pdb /version:0.0 -machine:x64 /INCREMENTAL:NO /subsystem:console -LIBPATH:C:\\root_src\\build\\lib Dict.lib C:\\root_src\\build\\lib\\libGui.lib C:\\root_src\\build\\lib\\libGpad.lib C:\\root_src\\build\\lib\\libGraf.lib C:\\root_src\\build\\lib\\libHist.lib C:\\root_src\\build\\lib\\libMatrix.lib C:\\root_src\\build\\lib\\libRIO.lib C:\\root_src\\build\\lib\\libMathCore.lib C:\\root_src\\build\\lib\\libImt.lib C:\\root_src\\build\\lib\\libThread.lib C:\\root_src\\build\\lib\\libCore.lib C:\\vcpkg\\installed\\x64-windows\\lib\\jsoncpp.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST:EMBED,ID=1” failed (exit code 1181) with the following output:
LINK : fatal error LNK1181: cannot open input file ‘Dict.lib’
ninja: build stopped: subcommand failed.

I tried to run the example from Linking ROOT libs with cmake in Windows - Newbie - ROOT Forum which worked so i assume that my root build is fine.

gui.cpp (3.2 KB)

CMakeLists.txt (986 Bytes)

main.cpp (239 Bytes)

LinkDef.h (64 Bytes)

gui.hpp (796 Bytes)

Please read tips for efficient and successful posting and posting code

ROOT Version: 6.36.06
Platform: Windows x64
Compiler: Microsoft (R) C/C++ Optimizing Compiler Version 19.38.33145 for x64


CMakeLists.txt (986 Bytes)

main.cpp (239 Bytes)

LinkDef.h (64 Bytes)

gui.hpp (796 Bytes)

gui.cpp (3.2 KB)

Welcome to the ROOT Forum!
I’ll take a look asap and come back to you.

Add set_target_properties(Dict PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE) after add_library(), as shown below:

add_library(Dict SHARED
    G__Dict.cxx
    gui.hpp
)
set_target_properties(Dict PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)

absolutely amazing - I hate that it was that simple after spending so long on it but thank you!

1 Like