vc++ vs2013 code with boost powered by nuget does not build - c++

I am quite new to VC++ and Boost.
My problem is that I want to use Boost 1.56.0 in my VC++ Visual Studio 2013 project (so I use vc120).
I have installed Boost via NuGet (https://www.nuget.org/packages/boost/). Everything seems to be okay, but when I try to build my project it says:
Fatal error LNK1104: Cannot open file "libboost_thread-vc120-mt-gd-1_56.lib".
Do you know where exactly the problem is and how I can fix it?
I thought installing a package using NuGet will do the whole job to get things working on its own.
I know that the linker can't find the lib file (actually there was no build process at all). But I don't know how I can fix this issue.
I think it is not a good idea to manually compile Boost with VC120 and add the lib folder to the additional paths of the linker. Why should I use NuGet then?
Any help is welcome - I am trying and searching the internet for so many hours now and I couldn't fix the problem.
Thank you,
Stefan

As mentioned before, Boost Nuget can't contain all possible compiled libraries for all possible configuration and compiler versions. However, there are separete precompiled Nuget packages and also source packages. Here is a list of all 1.56.0 Boost Nuget packages https://getboost.codeplex.com/releases/view/126256
In your case, I would suggest to use precompiled boost_thread-vc120.1.56.0. Not 1.57 yet!
If you are lazy, you can also use boost-vc120.1.56.0 which depends on all precompiled Boost libraries for Visual Studio 2013.

It seems that the latest version of NuGet for boost doesn't include every lib and dll files package (source).
You should install boost_thread altogether.

BlueGo is a tool which builds Boost using Visual Studio 2010/12/13. You just have to start the application, select your configuration and hit the Build button- everything else works automatically.
It can be downloaded here: https://bitbucket.org/Vertexwahn/bluego

Since the NuGet packet of Boost does not contain the lib files anymore, because the package is getting to big, I have decided to build Boost by my own.
I followed this instructions: Build Boost for Visual Studio - also read the second post!
I saw it too late but maybe it is helpful for somebody else:
There are pre-build Boost installer!
Here you can download an installer, which will install Boost (of specific version) for 32/64 bit (depending on which file you choose). There are also already different versions (vc100, vc110, vc120) available.
The problem when you use NuGet is, that you have
Install the Boost package (to get the source files)
Install the lib files (see the link Marco A. provided)
This can be very cumbersome since not all libraries of Boost are available. E.g. the lib files of ASIO were missing. So if you need them you have to compile it again by your own. So you mess up your project with NuGet packages and self-compiled boost libs. If NuGet provides everything you need I would use the NuGet way.
Finally, as I said I need the ASIO lib and therefore I have finally compiled Boost by my own. It seemed so easy to just use a NuGet Package.
Thank you all for your help.

Related

Installing Boost v1.70 in Visual Studio 2019 using Nuget

I'm learning C++, some of the Boost libraries and VS2019 Community Edition. I'm currently reading through the Boost website's online material and the book Learning Boost C++ Libraries, trying to follow along. I would like to update to 1.70.0 and figure out exactly why my code is building correctly. I know, I know...if it's working why question it? Well, the truth is I just don't understand why!
I wasn't aware of Nuget and vcpkg prior to downloading and installing Boost 1.68.0 manually (BTW, there seems to be way too many ways of installing the libraries and it's quite confusing). I have since deleted the original Boost installation directory and tried to install the Boost libraries through Nuget in VS2019. This didn't appear to be successful (although I suspect vcpkg (see below) has something to do with it). I was getting a single linker error (can't find the .lib file) which I eventually resolved (don't ask me how...it's a confusing story involving creating a new project and cutting/pasting my code. Now it works; go figure).
Currently, when I begin an #include directive () in my code I can see the path to the files which is buried under D:\...\vcpkg\installed\x86-windows\include\boost. I've never used vcpkg directly so I have no idea why it's there. The Property Pages for the project don't list the paths under C/C++ > Additional Include Directories or under Linker > Additional Library Directories so I haven't a clue from where the compiler and linker are getting the references. There appear to be no packages installed under the Nuget UI.
Ideally, I would like to start over with the Boost installation and use VS internal tools to do so. I will probably have several different VS solutions as I explore Boost and would prefer Boost to be available to all future projects. Is that possible?
Any advice?
One thing to keep in mind is that the "boost" package only installs the header only libraries, it doesn't install all the libraries that require a binary library.
To install the binary libraries, you need to install individual packages, for instance "boost_log-vc141" is the boost logging library.
First, install the boost package into your project using NuGet. You should see a packages.config added to your project that looks like this:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="boost" version="1.70.0.0" targetFramework="native" />
</packages>
Next, include the desired boost header file:
#include <boost\array.hpp>
You can confirm that the header is being loaded from the correct path by placing the caret after the hpp, pressing CTRL+SPACE, then hovering hovering over the item in the context list:

How to install system-wide nuget packages?

How can I install a nuget package system-wide on visual studio 2015?
I mean, yeah, you can install nuget packages per-project and per-solution... but, is it possible to install them system-wide so they'll be available for sources using vs2015 compiler?
Right now I'm coding some swig c++ modules to be used on python with cmake and having these libraries available system-wide so I can include them like any other system header would be quite convenient.
Just to clarify, the generated project by cmake will be ninja(using vs compiler)+ST (no package manager involved)... but still I'd like to be able of using the goodies provided by nuget to have my library set ready to be used by the swig modules
Nuget package management system does not have a "system-wide" install mode.
Downloaded packages are cached, so that you are not forced to re-download them each time for each project/solution referencing them.
You can also specify a path where to put the packages, but as far as I know for C++ projects this has some drawbacks, including the fact that project files are injected with *.props file paths relative to the solution, that causes Nuget system to be hardly usable from same projects included in different solutions at different path levels.
It seems that Microsoft is moving toward a different package manager for C++ native projects, you may want to look at VCPKG on Github.

C++ how to manage dependencies (use libraries from github for example)

I'm very new to C++ world, so please, sorry for such a dummy question. I googled a little, but wasn't able to find a proper answer.
My question is fairly simple - how should I use libraries in C++ world. For example in Java - there is maven and gradle for this task. In Python - I use pip. In javascript npm and bower do all the stuff. In C# you use nuget or just adding DLL lib to your project. But looks like in C++ things isn't such easy.
I found a tool, called conan but amount of libraries they have is pretty small and does not include any what I'm looking for.
So, for example - I want to use nlp lib meta but it seems like they don't provide any installer files. So I assume I need to get sources from Github. Should I compile them and then try to add the compiled files to my project or do I need to have a lib folder in my project, and put meta's sources in those folder and after operate with meta's sources as they are in my project?
My question isn't about how to install specific meta lib, but more from the source management point of view. If I use Visual Studio on Windows for example, but my colleague will be coding Clion under Linux. And I don't know the proper way of managing dependencies in C++ world.
C++ doesn't have anything like pip or npm/bower. I don't know if maven or gradle can be persuaded to handle C++ libraries.
In general, you are going to have to end up with
Header files in a directory somewhere
library files (either static libraries, or DLLs/shared objects). If the library is a header-only library like some of the boost libraries, then you won't need this.
You get hold of the library files, either by building them on your machine (typical for open source projects, and projects aimed at Linux platforms), or by downloading the pre-compiled binaries (typical for Windows libraries, particularly paid-for).
Hopefully, the instructions for building the library will be included on the library website. As noted in the comments, 'meta' seems to be quite good at that.
When you try to compile with the library, you may need a command line option (eg -I) to specify the directory containing the header files, and you may need a linker option (eg -l) to tell the linker to link against your library.
Cget will install any package that uses standard cmake, and works for linux and windows. It has shorten syntax for getting packages directly from github(such as cget install google/googletest).
In addition, dependencies can be automatically downloaded as well by listing them in a requirements.txt file.
There is also recipes for installing non-cmake packages and the repository here has over 300 libraries(and growing). So you can install curl with just cget install pfultz2/cget-recipes curl.
C++ sadly has no package manager for libraries. Some are out there and try to be one which are still small and scattered though (like conan).
In linux you have some "-dev" packages you can install but they are also not "all".
You most likely end up downloading them yourself. Next though is you have the problem of integrating those libraries. You have different build systems per operating system so you have to see how you build c++ files.
Like in windows with Visual studio you have to get a visual studio project or a nmake compatible makefile to build the libraries and then add them to your project. Same with linux makefiles.
There are several build frameworks who are higher level like cmake. The example you have in your post also works with CMake. So integrating that one into a cmake build environment would be easier but this only applies for other libraries also trying to use/integrate cmake build environments to it (e.g. boost / qt is doing this).
Yeah these are some thoughts to this. Sadly there won't be an easy/definitive answer to this because there is no real central c++ packet repository which is also integrated into a build system.
It appears to me that the Crascit/DownloadProject could be of help in your situation. It provides CMake plugins for downloading projects from a git repository by specifying tags, etc. Then you can use add_custom_target to run commands you need to have the project built.
There are a number of popular C++ released via nuget packages.
You can search on the gallery for them, usually using the native or c++ tags. Obviously you need a nuget manager for your OS, and I'm pretty sure that the C++ nuget packages rely on MSBuild for a lot of the grunt work, so you may have trouble getting a non-Visual Studio oriented setup to work nicely.
Also Gradle actually does have some support for native dependencies as well. I had a look at little while ago but the work on it was curtailed because the support for VS 2015 was lacking.
I recommend vcpkg for cross platform development. It has a number of IDE integrations. GitHub project is here.
I do cross platform development using tools like CMake, Visual Studio, WSL. vcpkg was incredibly helpful.
I started new project... in cureent time it's just "source package manager" you can provide some source code on github and then it will be just copy to you project (based on cmake + auto generating cmake files)
So links here:
https://github.com/wsjcpp/wsjcpp

Build boost.Log on Windows 7

I recently downloaded http://boost-log.sourceforge.net/libs/log/doc/html/index.html but I can't seem to find out how to build it. The rest of my boost lib was installed by using the installer, so all I did was selecting the files I wanted to include.
So how do I build Logs? Building for windows is completely new to me and I would really appreciate any help!
EDIT
Merge boost.log in the boost directory structure first.
Did you build boost ? If not, you have to go to your boost directory, run boostrap.sh and then run b2.exe. That will build all boost libraries.
Since you are on Windows, boost supports automatic linking, i.e. you just include the header files and the required libraries will be linked automatically when building your project from Visual Studio.

How to include boost::filesystem into a VS2010 project without adding a dependency on bjam?

According to this answer, the intended way to include non-header-only parts of Boost into a Visual Studio 2010 project require the use of bjam to build the correct libraries.
What is unclear to me is whether this is a one-time-only thing, where I just check in the lib files produced by bjam, or whether anyone who wants to build my project will from now on require not only Visual Studio but also bjam.
The project only targets Windows 32-bits, because it builds a plugin for a program that's only available in this configuration, and only needs to support the statically-linked multi-threaded CRT.
(For the record, if I just include the relevant .cpp files into the build, the compile stage succeeds, but at link stage I get a missing library error, which is apparently caused by the "auto-link" feature. Perhaps I should just disable auto-linking, if it's possible?)
You don't need bjam. Like yasouser answered, you can download the installer from boost pro, the downsides being that
you need to register though that's quick and easy
it's usually/sometimes a release or two behind the latest boost release.
What is unclear to me is whether this is a one-time-only thing, where I just check in the lib files produced by bjam, or whether anyone who wants to build my project will from now on require not only Visual Studio but also bjam.
It is a one time thing per machine. Once you have the boost binaries you don't need bjam anymore. The nice thing about the installer is that you can install some selected versions of the boost libraries + the headers (You can select VS version, single-threaded, static/dynamic, etc. on a per library basis e.g. thread, system, etc.) and then at a later point you can just run the installer again and add other binaries.
So if you're auto-linking and are missing a specific lib, just run the installer again.
FYI, you can disable boost's autolinking option by defining BOOST_ALL_NO_LIB and then manually linking in the lib versions you want.
Some of the boost libraries require you to build them as static or shared libraries and link them in your project. Either you can download the source and build it for yourself using bjam or you can install the pre-built binaries from here.
Yes this is a one time install (if you are installing from pre-built binaries or built by yourself). And those building your project will also need to do the boost install once for them to be able to build your project.
if I just include the relevant .cpp
files into the build
Direct including cpp files has many drawbacks. The only reason of borrowing .cpp files I can imagine is to allow build the project on other PCs without installing boost there. But I think it can be solved by distributing particular boost .lib files as well.