Reputation: 61
I'm an amateur in programming. I was wondering how I can use boost's serialization only (https://www.boost.org/doc/libs/1_36_0/libs/serialization/doc/index.html).
When I download boost, it has many libraries and is a big folder, but I just want to use the serialization library. Does my user need to install of all boost in order for me to use serialization?
I'm a complete beginner, so if you can tell me each step I need to do to get serialization into my project, it'll be much appreciated. For example, do I have to statically link a library? I have no idea. Thank you for your help.
edit: I want my user to not have to deal with much. So is there a way to use boost without having the user to install anything? Thank you.
Upvotes: 1
Views: 1278
Reputation: 27766
Does my user need to install of all boost in order for me to use serialization?
When you link boost, the MSVC++ and MFC runtimes statically into your application, you get a single executable, that includes all dependencies. Then all your user has to do is double-click the .exe file of your application.
Building boost libs from scratch can be tricky, so for getting started I recommend to download prebuilt binaries. Make sure to download the package that exactly matches both your version of Visual C++ and the bitness (32/64) of the application you are building. Though in the long run, it can be beneficial to build boost yourself, so you don't depend on the prebuilt binaries being up-to-date for the most recent version of VC++.
Make sure to add the directory path of the .lib files to your project's library path. You don't need to specify individual .lib files because boost uses auto-linking. In case you need to know, the static lib files include "mt-s" in the file name (e. g. "libboost_serialization-vc141-mt-s-x32-1_68.lib" for the 32-bit release version and "libboost_serialization-vc141-mt-sgd-x32-1_68.lib" for the 32-bit debug version).
In your project settings, make sure to choose MFC static library ("Generic" category > "Use of MFC"). Also choose "Runtime Library" > "Multithreaded" (/MT) or "Multithreaded Debug" (/MTd), depending on your project configuration (C/C++ category). If you don't do this, the linking will fail or you will link to the boost DLLs instead.
Upvotes: 0
Reputation: 393174
You usually need to link the "link library" (traditionally a .lib file on windows) that matches the "dynamic library" (.dll) at runtime. Of course, at runtime it needs to exist, so you need it "installed" (present at the target machine, in a compatible form, so matching the OS and architecture).
The good news:
Note that you may need indirect requirements (such as Boost System).
Indeed, you can XCOPY-deploy the libraries in the same folder as the exe file, but that's not really a common approach and might not be the best idea if you have little experience.
If you can get your hands on a (free) installer builder (a quick google leads to things like https://www.techrepublic.com/blog/five-apps/five-apps-for-creating-installation-packages/) you'll enjoy the guidance of tools that know the intricacies involved.
Upvotes: 1