LINK : fatal error LNK1104: cannot open file 'libboost_serialization-vc142-mt-s-x64-1_80.lib'

55 Views Asked by At

Platform: Windows 10, Visual Studio VC142

I'm using Boost 1.80.0 in my project. I've built Boost and been using modules such as Container without issue, however I tried to use Boost.Serialization and I get a link error:

LINK : fatal error LNK1104: cannot open file 'libboost_serialization-vc142-mt-s-x64-1_80.lib'

When checking the directory full of .lib files, I see similar files but nothing with -mt-s-x64:

Windows File Explorer inside C:/code/boost_1_80_0/stage/lib

I am seeking insight on why the linker is looking for this lib which the setup process (bootstrap, build) does not emit.

My pre-compile command:

@call cl.exe ^
/c ^
/Ycstdafx.hpp ^
src/stdafx.cpp ^
/Yustdafx.hpp ^
/Fo:obj_debug\ ^
/Fe:dist\swan_debug.exe ^
/Fd:dist\vc140_debug.pdb ^
/I"C:/code/glfw" ^
/I"C:/code/boost_1_80_0" ^
/std:c++20 ^
/W4 ^
/EHsc ^
/MP ^
/MT ^
/D_CRT_SECURE_NO_WARNINGS ^
/Zi ^
/link ^
/DEBUG:FULL ^
/NODEFAULTLIB:MSVCRTD ^
/NODEFAULTLIB:LIBCMT ^
/LIBPATH:"C:/code/glfw" ^
/LIBPATH:"C:/code/boost_1_80_0/stage/lib" ^
glfw3.lib ^
opengl32.lib ^
gdi32.lib ^
shell32.lib ^
kernel32.lib ^
msvcrt.lib ^
ole32.lib ^
shlwapi.lib ^
Pathcch.lib

My main compile command:

@call cl.exe ^
src/all_in_one.cpp ^
obj_debug/imgui_demo.obj ^
obj_debug/imgui_draw.obj ^
obj_debug/imgui_impl_glfw.obj ^
obj_debug/imgui_impl_opengl3.obj ^
obj_debug/imgui_tables.obj ^
obj_debug/imgui_widgets.obj ^
obj_debug/imgui.obj ^
obj_debug/stb_image.obj ^
obj_debug/stdafx.obj ^
/Fo:obj_debug\ ^
/Fe:dist\swan_debug.exe ^
/Fd:dist\vc140_debug.pdb ^
/Yustdafx.hpp ^
/I"C:/code/glfw" ^
/I"C:/code/boost_1_80_0" ^
/std:c++20 ^
/nologo ^
/W4 ^
/EHsc ^
/MP ^
/MT ^
/D_CRT_SECURE_NO_WARNINGS ^
/Zi ^
/link ^
/NATVIS:swan.natvis ^
/DEBUG:FULL ^
/NODEFAULTLIB:MSVCRTD ^
/NODEFAULTLIB:LIBCMT ^
/LIBPATH:"C:/code/glfw" ^
/LIBPATH:"C:/code/boost_1_80_0/stage/lib" ^
glfw3.lib ^
opengl32.lib ^
gdi32.lib ^
shell32.lib ^
kernel32.lib ^
msvcrt.lib ^
ole32.lib ^
shlwapi.lib ^
Pathcch.lib ^
Dbghelp.lib

Compiler output:

all_in_one.cpp
Microsoft (R) Incremental Linker Version 14.29.30148.0    
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:dist\swan_debug.exe
/debug
/NATVIS:swan.natvis
/DEBUG:FULL
/NODEFAULTLIB:MSVCRTD
/NODEFAULTLIB:LIBCMT
/LIBPATH:C:/code/glfw
/LIBPATH:C:/code/boost_1_80_0/stage/lib
glfw3.lib
opengl32.lib
gdi32.lib
shell32.lib
kernel32.lib
msvcrt.lib
ole32.lib
shlwapi.lib
Pathcch.lib
Dbghelp.lib
obj_debug\all_in_one.obj
obj_debug/imgui_demo.obj
obj_debug/imgui_draw.obj
obj_debug/imgui_impl_glfw.obj
obj_debug/imgui_impl_opengl3.obj
obj_debug/imgui_tables.obj 
obj_debug/imgui_widgets.obj
obj_debug/imgui.obj
obj_debug/stb_image.obj
obj_debug/stdafx.obj
LINK : fatal error LNK1104: cannot open file 'libboost_serialization-vc142-mt-s-x64-1_80.lib'
2

There are 2 best solutions below

0
Mohammad Alavi On

As you can see you do not have the file "libboost_serialization-vc142-mt-s-x64-1_80.lib" in the library path you have provided. The usual way I look for missing .lib or .dll files is using Everything. Search for the .lib file using this app in you system and if you find it, put it in your library search path.

4
john On

Not all boost modules need a library (some are header only) which is why you've been able to use boost up 'til now.

The name of the missing library indicates that it is a static library rather than an import library linking to a DLL.

This gives you one way to resolve the problem. If you change your project to link with the C/C++ runtimes dynamically then boost will also switch to dynamic linking. Use the /MD option not the /MT option, IIRC it's under C/C++/Code Generation in Project Properties.

But if you don't want to do that then you have to build a static version of the boost libraries. Instructions for doing that are here.