1
votes

I am attempting to build boost v. 1.53 for the first time and am getting this error message:

Error 1 error LNK1104: cannot open file 'libboost_date_time-vc110-mt-gd-1_53.lib' C:\Users\ryant_000\documents\visual studio 2012\Projects\Phase 2\Phase 2\LINK Phase 2

I have C:....\boost_1_53_0 in my include directories and C:...\boost_1_53_0\stage\lib on my additional dependencies on the linker menu.

What file am I missing to link in I can't find it after scouring the documentation?

Thanks a lot.

2
Maybe a bit redundant question but I want to make this very clear: You get the linker error while building the boost libraries? Not your production code (using boost libs)? - TobiMcNamobi
Assumed that the answer is yes: Have you checked if the file is actually there (in the appropriate directory)? Have you followed the build instructions provided at boost.org? - TobiMcNamobi
Do you have libboost_date_time-vc110-mt-gd-1_53.lib file in C:...\boost_1_53_0\stage\lib? - Igor R.

2 Answers

8
votes

For all it's loveliness and claims of being a header-only collection, boost does have some parts that need to be built into libraries in order for you to use them. One of these libraries is date_time. Boost is friendly in the sense that it will automatically link the correct .lib file for you when you #include a library, based on your compiler options. The caveat is that you need to have built the libraries first.

The file you're missing is libboost_date_time-vc110-mt-gd-1_53.lib, which we can see from the naming convention is the multi-threaded, debug version, using the debug runtimes, for VC11 (that's Visual C++ 2012 to you and I). It's possible that you simply haven't built that specific version of the libraries - boost by default performs a minimal build, skipping several versions of the libraries. Although it takes a bit of time, I find it's good to build everything in boost... hey, hard drive space is cheap!

Open up a Visual Studio command prompt, and make your way to the boost directory:

C:\> cd boost_1_53_0
C:\boost_1_53_0\> bootstrap.bat vc11
C:\boost_1_53_0\> .\b2 --build-type=complete toolset=vc11
... now go and make yourself a cup of tea

It will take some time, but it should build all combinations of every library. You can speed it up a little on a multi-core machine by adding, for example, -j4 to the .\b2 command line, which will build four things at a time.

The vc11 part defines the toolset to be used, which is handy if you have two compilers - in theory it shouldn't be necessary (boost does a good job of finding the correct toolset), but it doesn't hurt to make sure.

If you want to test that this is the issue, then you can specify to just build all combinations of the missing date_time library instead:

C:\boost_1_53_0\> .\b2 --build-type=complete toolset=vc11 --with-date_time
... now go and make yourself a cold drink, this won't take so long
1
votes

Change the content of the below files in boost folder( which is downloaded and extracted)

Folder : boost_1_54_0\tools\build\v2\tools Files: 1. msvc.jam

content changed :

for 32 bit : toolset.flags msvc LINKFLAGS console : /subsystem:console,5.01 ;

for 64 bit: toolset.flags msvc LINKFLAGS console : /subsystem:console,5.02 ;

  1. msvc.pycontent changed : for 32 bit : toolset.flags('msvc', 'LINKFLAGS', ['console'], ['/subsystem:console,5.01'])

for 64 bit: toolset.flags('msvc', 'LINKFLAGS', ['console'], ['/subsystem:console,5.02'])Folder : boost_1_54_0\tools\build\v2\engine Files: 1. build.bat content changed : for 32 bit/ 64 bit : 1. fix the Visual Studio Path Exactly like instead of "%ProgramFiles%- change to %ProgramFiles(x86)%

   2.   Add " /D _USING_V110_SDK71_ " to BOOST_JAM_CC =cl command before Skip_VC11Open vs2012 developer Command prompt and type the following commands

** update 7.1A SDK path as per your installation

call "%ProgramFiles(x86)%\Microsoft Visual Studio 11.0\VC\bin\vcvars32.bat"

set INCLUDE=%ProgramFiles(x86)%\Microsoft SDKs\Windows\7.1A\Include;%INCLUDE%

set PATH=%ProgramFiles(x86)%\Microsoft SDKs\Windows\7.1A\Bin;%PATH%

set LIB=%ProgramFiles(x86)%\Microsoft SDKs\Windows\7.1A\Lib;%LIB%

bootstrap

Pick the command as per the OS Type (32/64 bit)

for 32 bit :

b2 toolset=msvc-11.0 variant=debug,release link=shared runtime-link=shared address-model=32

for 64 bit :

b2 toolset=msvc-11.0 variant=debug,release link=shared runtime-link=shared address-model=64

To compile any sample for release and debug versions follow this:

Open vs2012 developer Command prompt and type the following commands

call "%ProgramFiles(x86)%\Microsoft Visual Studio 11.0\VC\bin\vcvars32.bat"

set INCLUDE=%ProgramFiles(x86)%\Microsoft SDKs\Windows\7.1A\Include;%INCLUDE%

set PATH=%ProgramFiles(x86)%\Microsoft SDKs\Windows\7.1A\Bin;%PATH%

set LIB=%ProgramFiles(x86)%\Microsoft SDKs\Windows\7.1A\Lib;%LIB%

go to the directory of the sample : ex: boost_1_54_0\libs\test\tools\console_test_runner

type the following command

\boost_1_54_0\bjam.exe --v2 toolset=msvc-11.0 variant=debug,release link=shared threading=multi runtime-link=shared