Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does C++ Boost distribution have `.dll`and `.lib` files?

Tags:

c++

dll

boost

Howdi folks. I'm currently in the process of creating a "shared" library (aka DLL on windows) which in turn would rely on "Boost C++" libraries for date time features. I have noticed that my Boost installation (done via Boostpro) has some DLL and LIB files in the lib directory of the boost installation. OK, I thought there were required so I added them to the library dependencies in my IDE.

Now what I do is write code which uses boost date time library, create a shared library and use it from a standalone executable. It works, even though I have just copied the shared library I created into the executable folder and not the boost_date_time-vc100-mt-1_47.dll file. Strange. Now what I do is remove the DLL/library dependency of Boost from my project and build the shared library. It still works.

I'm a bit confused. If the Boost libraries are really header only, why does my Boostpro installation have *.lib and *.dll files for datetime and other boost parts? Is there any scenario I'd want to use them given that those boost libraries anyways get compiled into my shared library?

Hope I was clear enough, please let me know if more clarifications are required. Also FWIW, I'm using Eclipse CDT + MingW for all this.

like image 839
sasuke Avatar asked Aug 18 '12 19:08

sasuke


1 Answers

Most parts of Boost are header-only while some other parts (at least filesystem and iostreams IIRC) require to link libraries. So it all depends on which parts of Boost you use. Which parts require linking is documented on the Boost Library Documentation page.

Some libraries use automatic linking. That means the header files contain compiler-specific code to embed instructions to link in the right libraries into the object files. This is an useful feature that has to be supported by the compiler. The gcc toolchains (including MingW) don't support that though.

like image 57
Sven Avatar answered Sep 19 '22 12:09

Sven