Automatically including libaries
Hi, this is a how-is-it-done question rather than a problem. Ive learnt a lot about c++ from using boost, but this one I just cant work out. I installed boost and it dumped all the libraries in c\boost\lib.Now I am slightly confused how I'm able to simply reference a header file in c:\boost\include\blahblah yet I don't have to include the specific libraries... somehow its done for me?! This is using visual studio, and whenever I have built lib files I have to include the header file as usual, but also have to explicitly drag the lib file into the project (or under the required libraries in the linker tab). Any idea how this is done? Would love to be able to do this with my libs! Cheers, Chris
Chris Morley wrote:
Hi, this is a how-is-it-done question rather than a problem. Ive learnt a lot about c++ from using boost, but this one I just cant work out. I installed boost and it dumped all the libraries in c\boost\lib.Now I am slightly confused how I'm able to simply reference a header file in c:\boost\include\blahblah yet I don't have to include the specific libraries... somehow its done for me?!
This is using visual studio, and whenever I have built lib files I have to include the header file as usual, but also have to explicitly drag the lib file into the project (or under the required libraries in the linker tab).
Any idea how this is done? Would love to be able to do this with my libs!
It's a feature of some Windows compilers that you can use "#pragma" to add linker instructions. How Boost uses/implements this is described in: http://www.boost.org/more/getting_started.html#auto-link Getting Started And: http://www.boost.org/libs/config/index.html#source Specifically it mentions the boost/config/auto_link.hpp header. I'm sure there's some VC docs on this also ;-) HTH. -- -- Grafik - Don't Assume Anything -- Redshift Software, Inc. - http://redshift-software.com -- rrivera/acm.org - grafik/redshift-software.com -- 102708583/icq - grafikrobot/aim - Grafik/jabber.org
This is using visual studio, and whenever I have built lib files I have to include the header file as usual, but also have to explicitly drag the lib file into the project (or under the required libraries in the linker tab).
A bit OT (ok a lot), but look at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang/html... you add something like #pragma comment( lib, "my_lil_ol_do_dad" ) to a header and bob's your aunty. Add a pinch of macro #ifdef magic for determining which lib for which configuration, brew for a bit and you're done. matt.
Chris Morley wrote:
Hi, this is a how-is-it-done question rather than a problem. Ive learnt a lot about c++ from using boost, but this one I just cant work out. I installed boost and it dumped all the libraries in c\boost\lib.Now I am slightly confused how I'm able to simply reference a header file in c:\boost\include\blahblah yet I don't have to include the specific libraries... somehow its done for me?!
This is using visual studio, and whenever I have built lib files I have to include the header file as usual, but also have to explicitly drag the lib file into the project (or under the required libraries in the linker tab).
Any idea how this is done? Would love to be able to do this with my libs!
Look at the #pragma comment(lib,"SomeLib.lib") directive.
Edward Diener wrote:
Chris Morley wrote:
Hi, this is a how-is-it-done question rather than a problem. Ive learnt a lot about c++ from using boost, but this one I just cant work out. I installed boost and it dumped all the libraries in c\boost\lib.Now I am slightly confused how I'm able to simply reference a header file in c:\boost\include\blahblah yet I don't have to include the specific libraries... somehow its done for me?!
This is using visual studio, and whenever I have built lib files I have to include the header file as usual, but also have to explicitly drag the lib file into the project (or under the required libraries in the linker tab).
Any idea how this is done? Would love to be able to do this with my libs!
Look at the #pragma comment(lib,"SomeLib.lib") directive.
To see how boost code does it look at www.boost.org/more\separate_compilation.html Robert Ramey
participants (5)
-
Chris Morley
-
Edward Diener
-
Matt Hurd
-
Rene Rivera
-
Robert Ramey