1

I am trying to build Quantlib using Boost Libraries.

I followed the instructions here: and also on the Quantlib website.

I downloaded and unzipped boost_1_57_0 into C:\program files

I then used the Visual Studio 2013 x64 Native prompt to go to the boost directory and ran

bootstrap.bat

and then

b2 --toolset=msvc --build-type=complete architecture=x86 address-model=64 stage

Then I opened Quantlib_vc12.sln in Visual Studio 2013.

Picked "Release" and "x64", opened "Quantlib" in Property Manager and set the VC++ Directories.

In the include directories I added C:\Programm Files\boost_1_57_0

In the Library Directories I added C:\Program Files\boost_1_57_0\stage\lib

Then I went to the Solution Explorer and right clicked and chose build.

I got one LNK1104 error.

LNK1104: cannot open file 'libboost_unit_test_framework-vc120-mt-1_57.lib

Please see attached screenshot:

enter image description here

I have no idea how to fix this and I would really appreciate some help. I had successfully installed this at work using an admin account but was not able to access Quantlib using my user account. I have since deleted and attempted installations atleast 15 times but it's not working. I am worried that all these attempts at installing may have messed something else up, like some registry (I have no idea how that works but I only know to be afraid). Please help! Thanks.

UPDATE: Still get the same error after adding BOOST_AUTO_LINK_NOMANGLE define to project.

enter image description here

UPDATE2: I am getting these messages on the screen while running b2 to build boost. Is this an error I need to fix?

enter image description here

Community
  • 1
  • 1
Amatya
  • 1,203
  • 6
  • 32
  • 52
  • 1
    According to the error you're getting, you don't have Visual Studio installed or it's installed somewhere that boost can't find it. Check to make sure you have it installed. If it is installed, you can run vcvars32.bat or vcvars64.bat from inside VISUAL_STUDIO_INSTALL_DIR\VC\bin and this will add all of the paths to these tools and such to your console environment. You should then be able to build. But honestly boost should have auto discovered it so I'm not sure if there isn't a deeper issue. –  May 12 '15 at 17:49
  • More here on manually setting up your path for building command line with visual studio. http://stackoverflow.com/questions/7865432/command-line-compile-using-cl-exe. Just note that wherever it says "Microsoft Visual Studio 10.0", you probably are running a newer version the the 10.0 at the end will probably be 11.0 or 12.0. Just adjust such paths as necessary when following those instructions, everything else should work the same. –  May 12 '15 at 17:52

1 Answers1

2

This is exactly what I warned you about in another related question/answer. What's happening here is that the boost headers you are including in this quantlib are (through macros) detecting that you're using MSVC, detecting the version, then automatically linking the required DLL files to build quantlib using #pragma comment(lib....). So even though under Project Settings -> C/C++ -> Linker there are no external DLL's or Lib's specified, they're still being linked by these pragma statements.

So when these macros are detecting your compiler and so on, they're dynamically building a string name of what they think the required libraries would be named on your system. Remember when you built boost, you specified the -layout option. This the naming layout of your boost libraries. Well by default, that layout is something like this:

LIB_LIBRARY_NAME_COMPILER_VERSION_SingleOrMultiThreaded_BOOST_VERSION.LIB

Which in practice looks like this:

libboost_unit_test_framework-vc120-mt-1_57.lib

This is boost "mangling" the name of your library to be as descriptive as possible about how the libraries were build so that, just by glancing at the file name, you know. What we do with -layout=system is tell the boost build system NOT to mangle the names, but to name them according to what option we gave to "layout". Since we chose layout=system, boost is going to name our libraries like this:

LIB_LIBRARY_NAME.LIB

Which in practice will produce:

libboost_unit_test_framework.lib

So when we start using boost after doing this (with MSVC only does this happen), these dynamically generated linker statements don't give a rip about or know about what -layout option you built boost with. They will attempt to link in required libraries using the fully mangled naming format, which is why you get the error:

cannot open file 'libboost_unit_test_framework-vc120-mt-1_57.lib

.. because you don't have a file named that! That's the mangled name! You have a file named libboost_unit_test_framework.lib. See the difference! So, you need to tell these stupid macros to stop mangling the library names when auto-linking required libraries. You do that by adding the following preprocessor definition to your Quantlib project:

BOOST_AUTO_LINK_NOMANGLE

You add that in Project Settings -> C/C++ -> Preprocessor -> Preprocessor definitions.

If you'd rather avoid this headache and don't care about the long and (imo ugly) mangling that boost does to library names, you can build boost omitting the -layout option and it will default to this mangled naming convention, where you shouldn't get stuck on this error at all anymore. I personally put out the effort to keep nice short/clean library names but it's all about preference.

Edit
Since you have the same error after fixing the NO_MANGLE problem, then the only possible reason that you're getting this particular link error is that you do not have whatever file the linker is complaining about missing stored in any of the directories supplied to the linker.

Verify the folders/paths you provide to the linker and verify that the file the linker is looking for is in one of the directories that you're providing to the linker. You have to provide directories to the linker because you're telling the linker "you can look in all of these places for the libraries my project needs". If you specify none, it's got nowhere to look. :(

Example:

Example of linker search directories Visual Studio 2013

  • I still got that error, but with a different filename. Error 1 error LNK1104: cannot open file 'boost_unit_test_framework.lib' C:\Program Files\QuantLib-1.5\test-suite\LINK testsuite – Amatya May 08 '15 at 23:17
  • @Amatya then make sure that you have the path to your boost libraries added to your linker options. Make sure you have a file named that in your boost/stage directory and then make sure you've added the boost/stage/whatever folder where all of your boost dll/lib files are to your linker options. Details on how to do that can be found in this answer: http://stackoverflow.com/a/20059167/562566, specifically point #3 –  May 09 '15 at 00:57
  • @Amatya I added a screenshot to help. It's a bit fuzzy because SO shrunk it down, but if you right click and "View Image" you'll see a nicer, more higher rez version. –  May 09 '15 at 01:07
  • I did a *.lib search in my boost_1_57_0 folder and I found nothing. Not a single file. I then went to boost/stage/lib and the folder is empty and has zero bytes size. Does this mean I have none of the lib files? When I did the b2 etc etc, shouldnt that have built the libraries? – Amatya May 10 '15 at 00:00
  • @Amatya yes indeed the instructions I provided in the previous q/a should have compiled out .dll and .lib files. You mentioned deleting and restarting over, perhaps this is why? Try re-running the commands. –  May 10 '15 at 00:42
  • I ran the b2 command again and took a screenshot of what was happening. Can you please take a look at it? It says something about 'cl' is not recognized. thx – Amatya May 11 '15 at 19:11