Hi, I am pretty new to C++ but have lots of experience in java/c# and know the basics (classes/structures/pointers etc) but am having some problems linking to external source libraries.

I am trying to use something called the openframeworks which I have downloaded and I need to include "\libs\openFrameWorks\ofMain.h" but when I do this it complains about all the includes that that file links to (which are in subdirectories of openFrameWorks folder) and I have to add a dependency to every subdirectory in the library.

Is there a better way of doing this, I understand that you cant automatically add all subdirectories but my Additonal Dependencies list is getting stupidly long.

Thanks in advance, sorry for being noobish

I'm not sure which compiler you're using, but usually you'd register any 3rd party libraries with your compiler.

e.g. In Visual Studio 2003 you'd:
In the Solution Explorer, right click on your project and select 'properties'.
In the property pages, select the 'C/C++->General' item in the tree.
Now select the 'Additional Include Directories' in the form and click on the '...' button. This will bring up a dialog which will allow you to add the path to the include folder of your library.
To do this, click on a blank line in the list (or add one using the folder icon and then select it). Next select the '...' button and use the popup dialog to navigate your way to the libraries include folder.

So that's the first part, the headers for your library are registered with the IDE. Next you need to ensure that the linker knows where to find the precompiled library files (usually found in the lib folder).

To do this, select 'Linker->General' in the tree and select the 'Additional Library Directories' item in the form and click on the '...' button that appears to bring up the 'additional library directories' dialog. As with the 'additional header directories' dialog, select a blank line (or add one using the folder icon and then select it) and use the '...' button to navigate to the lib directory for your library.
That done, click OK on all of the open dialogs and that's it! Your library is registered with the IDE.

Now in your project you should be able to use the library without having to add loads and loads of includes into your code. You'll only need to include the main header/headers for the library instead of every single one of them. And you'll be able to declare them like:

#include<"yourlibraryheader.h">

Instead of:

#include<"C:\path\to\library\yourlibraryheader.h">

Which I assume is more or less how you're currently using them!

The instructions I've included are for VS2003, but the steps should be similar for 2005 and 2008.

If you're using any other IDE, you'll have to refer to the manual for your compiler. Most compilers nowadays have the ability to register additional headers/libraries in this way.

Hope this has helped,
Cheers for now,
Jas.

This article has been dead for over six months. Start a new discussion instead.