Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linker error when building examples using cmake in Visual Studio 2019 #53

Closed
chrisabr opened this issue Nov 6, 2019 · 6 comments
Closed

Comments

@chrisabr
Copy link

chrisabr commented Nov 6, 2019

Hey,

I am trying to build the project in Visual Studio 2019, building it as a CMake project. I get the linker error:

"fatal error LNK1104: cannot open file 'libboost_date_time-vc142-mt-gd-x64-1_70.lib'"

I just dont understand where the dependancy on boosts date_time comes into play. Another curious thing is that it is only building complete.cpp and pluginmanager.cpp that fails. The exe files to filesession.cpp and simplelocalsession.cpp are building correctly without errors. Hope you could shed some light on this issue.

If any other information is needed, please let me know

@daniele77
Copy link
Owner

Thank you @chrisabr
I've got just a couple of questions for you.

  • the cli library comes with a visual studio solution file (in addition to the cmake file): have you tried to use that? Does it compile that way?
  • are you trying to compile just the examples or the test, too? What command line are you using to execute cmake?

@chrisabr
Copy link
Author

chrisabr commented Nov 6, 2019

Thank you for quick response!

  • Tried to build using the visual studio solution, and both complete and pluginmanager fails as before, with the same error message.

  • Currently I am only trying to build the examples.

I use Visual Studio to generate the cmake cache, and building. In other words I create the project as a default CMake solution in VS with default settings. I will include the command line args which visual studio uses. Please excuse the massive text dumb.

"Command line: "cmd.exe" /c ""C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe" -G "Ninja" -DCMAKE_INSTALL_PREFIX:PATH="C:\Users\chrib\Documents\cli-master\out\install\x64-Debug" -DCMAKE_CXX_COMPILER:FILEPATH="C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.23.28105/bin/HostX64/x64/cl.exe" -DCMAKE_C_COMPILER:FILEPATH="C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.23.28105/bin/HostX64/x64/cl.exe" -DCMAKE_BUILD_TYPE="Debug" -DCMAKE_MAKE_PROGRAM="C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" "C:\Users\chrib\Documents\cli-master" 2>&1"

Making the cache works perfectly. However when I build, I get this output:

cmd.exe /C "cd . && "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E vs_link_exe --intdir=examples\CMakeFiles\complete.dir --rc=C:\PROGRA2\WI3CF21\10\bin\1001831.0\x64\rc.exe --mt=C:\PROGRA2\WI3CF21\10\bin\1001831.0\x64\mt.exe --manifests -- C:\PROGRA2\MICROS1\2019\COMMUN1\VC\Tools\MSVC\14231.281\bin\Hostx64\x64\link.exe /nologo examples\CMakeFiles\complete.dir\complete.cpp.obj /out:examples\complete.exe /implib:examples\complete.lib /pdb:examples\complete.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console C:\local\boost_1_70_0\stage\lib\boost_system-vc142-mt-gd-x64-1_70.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ."
FAILED: examples/complete.exe
cmd.exe /C "cd . && "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E vs_link_exe --intdir=examples\CMakeFiles\complete.dir --rc=C:\PROGRA2\WI3CF21\10\bin\1001831.0\x64\rc.exe --mt=C:\PROGRA2\WI3CF21\10\bin\1001831.0\x64\mt.exe --manifests -- C:\PROGRA2\MICROS1\2019\COMMUN1\VC\Tools\MSVC\14231.281\bin\Hostx64\x64\link.exe /nologo examples\CMakeFiles\complete.dir\complete.cpp.obj /out:examples\complete.exe /implib:examples\complete.lib /pdb:examples\complete.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console C:\local\boost_1_70_0\stage\lib\boost_system-vc142-mt-gd-x64-1_70.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ."
LINK Pass 1: command "C:\PROGRA2\MICROS1\2019\COMMUN1\VC\Tools\MSVC\14231.281\bin\Hostx64\x64\link.exe /nologo examples\CMakeFiles\complete.dir\complete.cpp.obj /out:examples\complete.exe /implib:examples\complete.lib /pdb:examples\complete.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console C:\local\boost_1_70_0\stage\lib\boost_system-vc142-mt-gd-x64-1_70.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:examples\CMakeFiles\complete.dir/intermediate.manifest examples\CMakeFiles\complete.dir/manifest.res" failed (exit code 1104) with the following output:
C:\Users\chrib\Documents\LINK : fatal error LNK1104: cannot open file 'libboost_date_time-vc142-mt-gd-x64-1_70.lib'

@chrisabr
Copy link
Author

chrisabr commented Nov 7, 2019

It seems like I got it to work by adding some in the CMake-file.

By using Boost::thread + Boost::regex instead of Threads I am able to build the examples successfully.

find_package(Boost REQUIRED COMPONENTS system thread regex)

target_link_libraries(cli INTERFACE Boost::system Boost::thread Boost::regex)

@daniele77 daniele77 changed the title Linker error when building examples Linker error when building examples using cmake in Visual Studio 2019 Dec 17, 2019
@daniele77
Copy link
Owner

I managed to reproduce the issue:

  • visual studio 2019
  • boost 1.72

Open the directory as a CMake solution, enable CLI_BuildExamples, disable CLI_BuildTests, specify boost paths.

The linker complains that libboost_date_time is missing, as reported.

I solved changing the following lines in CMakeLists.txt:

#find_package(Boost` 1.55 REQUIRED COMPONENTS system)
find_package(Boost 1.55 REQUIRED COMPONENTS system date_time regex)
...
#target_link_libraries(cli INTERFACE Boost::system Threads::Threads)
target_link_libraries(cli INTERFACE Boost::system Boost::date_time Boost::regex Threads::Threads)

(i.e. I added boost date_time and regex to the project).

However: where those dependencies come from? Anyone can help me with this?

@daniele77
Copy link
Owner

I fixed the problem. The latest commit should now work. At least, oN my PC it does compile correctly :-)

@chrisabr : could you please test the latest commit and tell me if I can close this issue?

Thank you very much.

@daniele77
Copy link
Owner

Fixed in commit fab1d75

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants