1

I'm currently trying to use boost for serialization in my project. I started by following this demo and making sure I could get boost working on Visual Studio:

https://www.boost.org/doc/libs/1_69_0/libs/serialization/example/demo.cpp

After following this demo, I added boost onto my project where I ran into some issues. When I change "Use Standard Windows Libraries" to "Use MFC in a Static Library" I get the error:

cannot open file 'libboost_serialization-vc141-mt-s-x32-1_69.lib'

More specifically this happens for the following includes.

#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>
#include <boost/serialization/list.hpp>

I'm new to boost, so what I'm wondering is why this would be occurring and how necessary these are for data storage. If fundamental, how would I go about fixing it?

Tarface
  • 21
  • 5

1 Answers1

0

The 'x32' in the error message filename indicates that "Use MFC in a Static Library" is trying to link with a 32 bit boost library and the s in the filename indicates that it requires a static library, see: how can I decode boost library namimg.

Your boost libraries are most likely built in 64 bit mode and may not be static. You can tell from the library filenames: 64 bit libraries have 'x64' in their filename, e.g.: libboost_serialization-vc141-mt-x64-1_69.lib is a 64 bit library that is not built for static linking to the C++ standard library and compiler runtime support libraries, because it does not have -s in the filename.

In which case, the solution is to build the boost serialization library in 32 bit mode, with runtime-link=static, see boost getting stared on windows.

kenba
  • 4,303
  • 1
  • 23
  • 40
  • Building boost yourself can be somewhat tricky for a beginner. There are myriades of build options. For beginners I recommend to download [prebuilt binaries](https://sourceforge.net/projects/boost/files/boost-binaries/). Also it can be helpful to add "/VERBOSE:LIB" to the linker command-line arguments to see where the linker is searching for the libs. – zett42 Mar 28 '19 at 21:46