naming convention not applied for boost libraries when built using VS2010 - c++

I just built Boost 1.54 using Visual Studio 2010. I am trying to link the built libs into my program and I am facing an issue there. The built libraries do not follow the Boost naming convention. For example, I have boost_atomic.lib instead of libboost_atomic-vc100-mt-1_54.lib
. When linking my program, VS errors out with the following error:
LINK : fatal error LNK1104: cannot open file
'libboost_atomic-vc100-mt-1_54.lib'
I checked my VS project and I do not refer to this anywhere. How do I fix this? Is there a flag that will generate Boost libs with the naming convention? If yes, I can rebuild boost. If not, how do I tell Boost to pickup the libs I have?
P.S: I did try adding boost_atomic.lib to additional libraries, but it keeps asking for that specific lib( I have defined BOOST_SP_USE_PTHREADS)

Related

does adding libraries in eclipse work the same way as in visual studio?

I used to code using visual studio,when linking boost libraries I just added the folder having libraries e.g boost/lib and vs automatically choose the required lib files and link against them.
Now I am trying to link to boost lib in eclipse.I added the /usr/loca/lib folder which has boost library files.
But undefined reference error happens to all boost libraries.
I read that I must add each library file by its name in eclipse.
Is this the only way ?Is there automatic way to choose the required library files like visual studio?
thanks for your help.
I assume by Eclipse you mean Eclipse with MinGW or Cygwin (both GCC-based toolchains).
Auto-linking (#pragma comment(lib ...)) is a Visual C++ feature that is not available in GCC.
With GCC you have to specify all the boost libraries that you're using when linking the program (including any libraries used by those libraries, like -lboost_system, etc.), in the right order.

Is Visual Studio adding dependencies from out of nowhere?

I'm having a problem building a windows C++ project with a specially modified version of the boost library. I'm not using bjam, but instead have a custom project using cmake to manage building a small sub-set of the boost libraries. Everything seems to compile fine, but then I get a linking error for an entity that was never mentioned in cmake or any of the source files:
2>LINK : fatal error LNK1104: cannot open file 'libboost_thread-vc100-mt-gd-1_54.lib'
I searched for this string in my build folder using 'findstr', and found it mentioned in thread.obj in this context:
/DEFAULTLIB:liboobst_thread-vc100-mt-gd-1_54.lib
My question is: where did this /DEFAULTLIB tag come from and how do I prevent it? I turned on explicit compile and linking flags ("Suppress Startup Banner"=No) and it is not mentioned anywhere during the build process.
Edit:
Per commenters, this is part of the auto-linking feature in boost, which can be disabled with the BOOST_ALL_NO_LIB definition. Described here.
Per the commenters, this is part of the auto-linking feature in boost, which can be disabled with the BOOST_ALL_NO_LIB definition. Described here.

linking to boost with visual studio 2013

I'm trying to link to several boost libraries (the ones that need to be compiled) in visual studio 2013 and am having trouble doing so.
I've installed the boost files by runing from the command line
boostrap.bat
and
b2 --toolset=msvc-12.0 --build-type=complete architecture=x86 address-model=64 stage
so that the libraries are in C:\boost_1_56_0/stage/lib
In my project I go into configuration properties>c/c++>General>Additional include directories and include C:\boost_1_56_0 and include headers using for example
#include<boost/serialization/vector.hpp> among others
I then go to configuration properties>linker>additional library dependencies and include C:\boost_1_56_0\stage\lib
I am now aware that boost uses auto linking so I ensure that there are no attempts to directing link to the boost libraries in configuration properties>linker>input>additional dependencies
However I still get (many) linker errors of the following type:
error LNK2001: unresolved external symbol "public: void __thiscall boost::archive::detail::basic_oarchive::end_preamble(void)" (?end_preamble#basic_oarchive#detail#archive#boost##QAEXXZ)
All the relevant questions I find concern misunderstandings of boost's auto linking facility, but I am now doing explicitly what I should be doing (to the best of my understanding). It is finding the the header files ok and the library files are where I am instructor the linker to look for them.
What might I be doing wrong?
There are tons of articles for linking boost in visual studio in stack overflow. One of them which I find minimal/complete is How to use Boost in Visual Studio 2010
I just run into similar question and share my idea with you.
You are probably compiling both 32bit and 64bit libs for boost. Thus I guess you maybe have two directories which contains the libs with the same names but built in different platform,like $(BOOST154_NEW_HOME)\lib_x64 and $(BOOST154_NEW_HOME)\lib_x86. You should have included both paths in your configuration properties>linker>additional library dependencies. Though boost are using auto_link to find out which lib you want to use, but it still confused about which lib under 32 bit or 64 bit need to be imported.
My suggestion is that you should include only 64bit boost libs directory in your configuration properties>linker>additional library dependencies.

How to link Boost in a dependent static library

In MS Visual C++ 2010
I had a single C++ project in my solution which used boost and worked perfectly.
I then decided to convert this project into a static library and create a new project which depends on this static library.
Now, my converted static library builds without errors and warnings (compiler and linker)
but the new project compiles but does not link.
I am getting:
1>LINK : fatal error LNK1104: cannot open file 'libboost_thread-vc100-mt-1_45.lib'
As a test I added the full directory path to the linker options for this library... and then it complained about
1>LINK : fatal error LNK1104: cannot open file 'libboost_date_time-vc100-mt-1_45.lib'
I have now added complete paths to all the libraries and it now builds and run.
I am not happy with this solution because:
I don't want users of the library to
have to worry about linking in
boost.
It is messy
I know an answer would be to create a DLL but is there a way to do this statically and keep the linking at my static library level.
Edit:
If I tell the .exe linker to ignore the boost libs explicitly then it all is ok except the .exe should not have to worry about boost at all.
/NODEFAULTLIB:"libboost_thread-vc100-mt-1_45.lib" /NODEFAULTLIB:"libboost_date_time-vc100-mt-1_45.lib"
Apparently you don't need the .libs, as your exe also links without them. You seem to be using boost header-only methods and classes. So just tell boost to disable auto linking by defining the preprocessor symbol BOOST_ALL_NO_LIB in your project.
If you want to make your .lib unnecessary big by including all of boost, this question seems to hold an answer (which I never really tried myself): Linking static libraries to other static libraries
When building your library, you can include the boost libraries in yours. To do so, in VisualStudio's Librarian > General property page, list your boost libraries as Additional Dependencies.
However, there may be a problem if your clients use boost themselves, and statically link to it (especially a different version than the one you are using).
Did you build boost library? There are certain libraries in Boost that needs to be compiled. In case if you haven't done that, refer to "Getting started in Windows" on how to build the Boost library.
EDIT-1: Boost can be built both as a static and dynamically loadable (dll) libraries.
EDIT-2: If you have already built Boost, then the answer by #Daniel Gehriger tells you how to add it in VS.

Boost autolinks libraries which are not built by Boost, but the intended ones are built

I am developing a Math application which can be extended by writing python scripts.
I am using Qt 4.6.3 (built as static library, debug and release versions) and Boost 1.43.0 (built as static library, runtime-link also set to static, multi-threaded version, debug and release). Everything is built with MSVC++2008. Boost built the following libraries:
libboost_python-vc90-mt-s-1_43.lib
libboost_python-vc90-mt-s.lib
libboost_python-vc90-mt-sgd-1_43.lib
libboost_python-vc90-mt-sgd.lib
My project compiles, but gives the following error during the linking phase:
1>Linking...
1>LINK : fatal error LNK1104: cannot open file 'boost_python-vc90-mt-gd-1_43.lib'
Why is it not selecting one of my compiled libraries?
I think the s in the library names stands for static, but then the auto-linking feature seems to select a dynamic library, and I want it all linked statically in one executable.
The same happens with the regex library: I have the same 4 regex libraries compiled and a quick test shows this linking error:
1>LINK : fatal error LNK1104: cannot open file 'libboost_regex-vc90-mt-gd-1_43.lib'
What to do?
You can define BOOST_ALL_NO_LIB. This prevents automatic linking of boost libraries and you must then link the required boost libs manually.
If 's' stands indeed for static (I don't know all those modifiers by heart), define the BOOST_ALL_DYN_LINK symbol while compiling (add it to the command line options). It tells boost to link to the DLL libraries. Alternatively, compile/install static boost libraries.
The problem is fixed, during the compilation of the boost libraries, I selected the link=static option. Which creates static libraries. I also selected runtime-link=static option, and this was wrong!
The solution for this problem was compiling boost with runtime-link=shared. Now some extra libraries are added, with the correct filenames, so the linker can find them. At first the compiler still searches for the dll library (boost_python-vc90-mt-gd-1_43.lib, instead of libboost_python-vc90-mt-gd-1_43.lib), everything else from boost links automatically to a static library, but because boost.python has a different auto-linkage set up, when you provide BOOST_PYTHON_STATIC_LIB, it finally links to the right library and it works!