Visual Studio - find out why Visual Studio tries to link to class X? [duplicate] - c++

This is what I have done:
Download the 1.54 zip file from the boost website
Extracted/copied it to C:\Program Files (x86)\Boost
Inside Visual Studio I have set the include libraries to: C:\Program Files (x86)\Boost\boost_1_54_0\boost_1_54_0\
(This seems to work fine for getting the compiler to accept the libraries)
Now the bit i'm having problems with- linker:
Inside Visual Studio I have set the linker include directories to: C:\Program Files (x86)\Boost\boost_1_54_0\boost_1_54_0\libs\
When I compile my project I get:
fatal error LNK1104: cannot open file 'libboost_date_time-iw-mt-sgd-1_54.lib'
EDIT Have built the boost binaries using the answer below. However I now have these files:
libboost_date_time-vc110-1_54.lib
libboost_date_time-vc110-gd-1_54.lib
libboost_date_time-vc110-mt-1_54.lib
libboost_date_time-vc110-mt-gd-1_54.lib
libboost_date_time-vc110-mt-s-1_54.lib
libboost_date_time-vc110-mt-sgd-1_54.lib
libboost_date_time-vc110-s-1_54.lib
libboost_date_time-vc110-sgd-1_54.lib
but still no
'libboost_date_time-iw-mt-sgd-1_54.lib'
EDIT: Think I have found the problem:
http://lists.boost.org/Archives/boost/2004/08/70114.php
OK, here's the problem: originally we had one Intel toolset:
"intel-win32" which created the library suffix "iw" (note no version
number!), and this is what the auto-link header currently searches
for.
However people have started adding versioned Intel toolsets, which
means that we now produce an ad-hoc mixture of library names, some
with compiler-version suffixes and some without, the autolink code
could handle either form, but as it's not psychic it can't handle
both :-(
Solution is to #define BOOST_ALL_NO_LIB

On a 64bit system you should build boost in Program Files, not Program Files(x86) the boost automatic library include does not handle the redirection correctly. Alternatively you can manually manage the library inclusion... but I would highly recommend against it.
Also a reminder that you need to build boost in all the flavors and bitnesses you are going to use. See How to use Boost in Visual Studio 2010 for a good example of how to do so.
In an administrator visual studio command prompt go to the boost directory
run bootstrap.bat
run b2 --toolset=msvc-10.0 --build-type=complete architecture=x86 address-model=64
wait for b2 to finish building
EDIT:
As it turns out the iw in that library refers to the intel compiler... to use that with boost and visual studio you'll need to follow the directions from Intel.

Related

Building protobuf for Linux using VS2017

I have configured VS2017 to build Linux C++ by remote building on a Linux Mint VM.
I tried a simple C++ program and it compiles and executes fine, the thing is that now I need to add a generated protobuf source and the linking fails constantly.
On the Linux VM the protobuf generated files are building correctly and I was able to execute the gRPC examples.
The errors I get when I build from VS2017 are a lot of:
undefined reference to 'google::protobuf::internal'
and there is also this one
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Application Type\Linux\1.0\Linux.targets(262,5): error : Illegal characters in path.
I think this is a VS2017 remote compilation configuration issue, but I don't know what could it be.
Has it happened to you? Do you know how to solve this issue?
Thanks
SOLUTION: I the project properties go to Linker > All Options > Library dependencies and add: protobuf;pthread;grpc++;grpc
This explains the "Illegal characters in path" message.
Does protobuf link to any libraries on the Linux system? Assuming you're not using CMake, have you added the libraries andtheir path(s) to the Visual Studio project - Library Dependencies and Additional Library Directories.
This might help with specifying libraries.

Visual C++ can't find libraries - depending on library folder order

I have a Visual C++ project that uses both CUDA and Boost. I have the following environment variables pointing to different libraries:
BOOST64_Lib = c:\boost\1_57_0\lib64-msvc-11.0
CUDA_LIB_PATH = c:\program files (x86)\NVidia\GPU Computing Toolkit\CUDA\v6.5\lib\x64
My VC++ Directories setting includes the following libraries:
$(BOOST64_Lib);$(CUDA_LIB_PATH);$(LibraryPath)
When I compile the project, I get an error saying cudart.lib can't be found. If I move $(CUDA_LIB_PATH) to the beginning of the VC++ Library directories, I get an error saying msvcprtd.lib cannot be found.
msvcprtd.lib exists in the proper place (VC\lib\amd64 under Visual Studio 2012). cudart.lib obviously exists in the CUDA library folder.
I'm using Visual Studio 2013, and the specific project is compiled with the Visual Studio 2012 (v110) Platform Toolset.
I must be missing something really small, that makes the linker complain about different libraries based on the order of library folders, but I can't find what that is.
Either set
CUDA_LIB_PATH = "c:\program files (x86)\NVidia\GPU Computing Toolkit\CUDA\v6.5\lib\x64"
or
LibraryPath = $(BOOST64_Lib);'$(CUDA_LIB_PATH)';$(LibraryPath)
To get informative build log set Tools / Options / Projects And Solutions / Build and Run/MSBuild output verbosity to Normal.

Easier way to specify Additional Library locations in Visual studio 2013

When i build the boost library, with the vs 2013 developer prompt,
>bootstrap
>b2
it will generate the lib files in an subdirectory:
bin.v2
every library is now saved as follows(example):
<path>\boost_1_55_0\bin.v2_x64\libs\log\build\msvc-12.0\debug\address-model-64\architecture-x86\link-static\log-api-winnt\threading-multi\libboost_log_setup-vc120-mt-gd-1_55.lib
Now when i try to build an app which uses logging, i will get an linker error because the
file 'libboost_log_setup-vc120-mt-gd-1_55.lib'
could not be opened. Now, when i specify the location of this file in the linker properties of my project and rebuild it another file is missing:
libboost_system-vc120-mt-gd-1_55.lib
rinse and repeat and yet another dependency will pop up, libboost_date_time-vc120-mt-gd-1_55.lib and so on, is there a smart way to solve this problem? like building the boost libraries in a way that the boost build programm will put them in one single folder or can i configure visual studio to search recursively for the libs?
Someone else asked a question on how to build x64 libs with bjam: 64-bit version of Boost for 64-bit windows
the answer also contained the answer to this concrete question:
after the bootstrap command, the bjam command goes as follows:
bjam --toolset=msvc-12.0 --build-type=complete allthelibs
where --toolset=msvc-12.0 corresponds to visual studio 2013
and allthelibs will be the subfolder containing all the boostlibs

Visual Studio 2013 (vs120) asks for wrong boost libraries

I'm trying to compile one of my projects on Windows 7, using Visual Studio 2013. I've installed Boost 1.53 and setup the solution using cmake.
What happens is that now the compiled libraries of boost are in the form libboost_*-vc120-mt(-gd)-1_53.lib. In the linker project options, under the input tab, I have verified that the libraries that I need are there, and in fact the compiler is able to correctly read them.
However, for some reason that I absolutely can't understand, the linker is also trying to find libraries compiled as vc110. For example:
error LNK1104: cannot open file 'libboost_filesystem-vc110-mt-gd-1_53.lib'
The Platform Toolset that is listed in the project option is "Visual Studio 2013 (v120)". I couldn't find any reference to vc110 in any of the project options. Can you help me understand what is happening?
This post thankfully solves my question. I wasn't able to find it before. The solution is to edit the boost/config/auto_link.hpp because the code inside is not able to handle vc120, and ends up suggesting vc110
How do I specify, which version of boost library to link to?
The library name is autogenerated in the boost header version.hpp
Possibly the version wasn't rebuilt, or you are pointing at the wrong header version?
Instead of patching the config file try just defining a macro before the header inclusion .. this is what I did in my project
//#define BOOST_LIB_TOOLSET "vc100"
//#include

how to install boost to the VS 2008?

I've almost completely installed Boost, but I have a problem with how to set my path to Boost in Tools->options->projects->VC++ Directories.
I've written the path to include files and libraries (my folder contains two subfolders, lib and include), but when I try to use Boost with
#include boost/regex.hpp, I got this linking error:
LINK : fatal error LNK1104: cannot open file 'libboost_regex-vc90-mt-gd-1_36.lib
Could you please tell me how to install Boost correctly for Visual Studio 2008?
Use the Boost Installer by the Boost consulting group.
You might be interested in the Visual Studio 2008 Feature pack. It adds many of the features that have only been available from Boost until now, the features that are part of the C++ TR1.
Also checkout this post for instructions on how to build Boost yourself.