• Advertisement
Sign in to follow this  

How to add external libraries to VC++ 6.0

This topic is 4740 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am trying to use external libraries in my C++ project. (Specifically, Boost multi-array) My question is how can I set my workspace to look in the folder where I have the boost libraries when I compile so I don't get error messages that is can't find the include files. I am using visual C++ 6.0 Thanks.

Share this post


Link to post
Share on other sites
Advertisement
You have to tell VC++ 2 things: where to find the libraries, and which ones to link from the location specified

Have your project open, go under Project->Settings in the menu bar. Go under the "Link" tab. Under the "Category" menu, select "Input". There will be a text box for "Additional Library Path". Enter the folder where you find your libraries.

Then you need to specify which libraries to load. There are two ways to do this. From the same place, you could go under the text box that says "Object/library modules". Enter one space after the last item, and enter the name of the library. Alternatively, you can do it directly in your source code:

#pragma comment( lib, "Your library name.lib" )

Share this post


Link to post
Share on other sites
Tools menu -> Options... -> Directories tab

From there, you can choose what type of files you want to add folders for in the dropdown box on the right. Picking "Include files", you can then add the folder you wish in the list below for header (.h) files. Picking "Library files", you can then add the folder you wish in the list below for library (.lib) files. Order can be important for certain libraries, especially when working with multiple versions of a library. Boost should probably be fine anywhere, though I haven't actually used it yet so I can't say for sure.

[edit]Oh yeah, and your project settings as well, like v0dKA said.[/edit]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
If You want to read a include file from work directory than You must use #include "includefile.h".
what kind of external libraries do You have on Your mind?? Static or dynamic??

Share this post


Link to post
Share on other sites
1) Go to 'Tools' and click on 'Options'
2) Click the 'Directories' tab
3) In the drop down lost select 'Library files'
4) Double click the empty list entry (Or click the 'New' button under the drop down list) and click the '...' button that shows up.
5) Browse to the library directory and then click 'OK'
6) Press 'OK' again to close the dialog

(Note: You may need to do it with the header files too (Include files))

Once that's done you can use:
#pragma comment(lib, "SomeLibrary.lib")
to use it.

(Don't forget to include the header files in your project too)

Share this post


Link to post
Share on other sites
Just on a personal note, I HIGHLY suggest #pragma comment(lib,"libraryname.lib")
I learned this method recently and it works and to me it looks better.

The reason for this is.

A. you can comment it.

B. If you need to move the files to another project you'll not need to resetup the project (except for the library directories).

C. It's much much nicer looking, and it's public.

As someone meantioned just remember the headers are #include <iostream.h>.

And remember if you set up the directories for Libraries make sure to set up the header directories (it'll be a different final folder, but the main directory is the same)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement