4

Where do I find the lib files for linking my program when using some Boost libraries? Decided to try its threading functionality but I am getting

Error 6 fatal error LNK1104: cannot open file 'libboost_thread-vc90-mt-gd-1_42.lib' InterviewPractice

after I include

Error 6 fatal error LNK1104: cannot open file 'libboost_thread-vc90-mt-gd-1_42.lib' InterviewPractice

I can't find where to get the .lib files for proper linking on the boost website? Any tips? :)

user229044
  • 232,980
  • 40
  • 330
  • 338
bobber205
  • 12,948
  • 27
  • 74
  • 100

6 Answers6

6

Some of the Boost libraries need to be built (the ones that use OS-specific functions, for example). You can build them yourself, or download a pre-built package.

GManNickG
  • 494,350
  • 52
  • 494
  • 543
  • Thanks for the info. I better schedule some time in to build all those libraries. xD I bet it'll take awhile. – bobber205 May 05 '10 at 18:47
  • 2
    @bobber205: grab the pre-built package and schedule a bunch of time to figure out how to build the entire boost distribution. It can take a few days to build under Windows the first time that you do it. The pre-built packages will get you up and running quickly. – D.Shawley May 05 '10 at 18:51
  • 1
    It take a little while sure, but a few days? What the heck are you doing? :D – KTC May 05 '10 at 19:00
  • 1
    @D.Shawley: Eek, a few days? I only remember it taking a couple hours, maybe. – GManNickG May 05 '10 at 19:00
  • @D.Shawley Even on my decrepit, 10-year old laptop, building the libraries only took a couple of hours, max. –  May 05 '10 at 19:10
  • Yeah, but it's complicated for people like me who never even used cmd for anything. That's why it takes a whole day: lots of research on the internet. – Leonard Inkret Nov 08 '19 at 15:57
2

An alternative solution I use is to create your own wrapper project with the bits of boost that you are using. Generally in VS.Net this is just a matter of just adding the cpp files from the boost/libs/blah subdirectory. They compile very cleanly so you don't normally need to do any other setting up of your project. I find this technique to be useful if you are wanting to automate builds from SCM and you don't want to check in binaries. It's also very fast as you only build the bits you need. Another advantage is that it's easier to create configurations that are relevant to your projects, ie Debug/Release, static/dynamic, 32/64 bit. One gotcha though is that you need to disable the auto-linking option by defining BOOST_ALL_NO_LIB when you build your project.

Alternatively, you'll need to use the jam tool to build the raw libraries for the configurations you require.

the_mandrill
  • 29,792
  • 6
  • 64
  • 93
  • 1
    IN conjunction with this, the bcp tool (provided in the boost distribution) will copy just the needed boost includes. This can help if you don't want all of boost in your SCM. – KeithB May 05 '10 at 21:24
  • Useful tip -- I never knew about that tool – the_mandrill May 06 '10 at 08:23
1

.lib files are often nested under a folder called stage, so you may need to replace boost/lib with boost/stage/lib in the Additional Library Directories section under your project properties. Section 6 and 6.1 of this tutorial describe this process, but do not include Boost's stage folder.

You can also do a file search for the broken .lib file to get an idea of the location.

Community
  • 1
  • 1
modulitos
  • 14,737
  • 16
  • 67
  • 110
0

It all depends on which operating system / compiler you're using.

I suggest you download the boost source code and learn how to build Boost.

Assaf Lavie
  • 73,079
  • 34
  • 148
  • 203
0

This problem is caused because Boost installation does not install threading libraries by default. You have to specifically select the threading libraries during installation. So, re-run the installation and select the threading library and select the version of your compiler to download appropriate files. In this case for file "'libboost_thread-vc90-mt-gd-1_42.lib" you need to select multi-threading for version VC++ compiler 9.0 debug with boost library version 1.42.

I hope this helps...

0

I hit the same link error using boost version 1.44 and the pre-built installer. I unzipped "libboost_data_time_vc100-mt-gd-144.zip" which contains only the missing .lib and this seems to have solved the problem.

tpc1095
  • 109
  • 1
  • 12