For the use of a package / library in C++ inside another program three things should be specified:

  1. Include file directory.
  2. Library directory (external programs are generally compiled in the form of static or dynamic libraries and those libraries are linked with the target program).
  3. Library names that would be used in the target program.

To specify include and library files there are three general approaches:

  1. Put the external program library files and include files in C++ default library and include folders which depend on the compiler and OS (recommended).
  2. If using IDEs such as Visual C++ and Eclipse one can add the external program library and include directories as “global” at places that would be shared for ALL C++ projects.
  3. For one particular program, one can specify required external include and library folders.

As can be seen level of generality goes from all programs to one particular program. Sometimes the 3rd option is the best if the given library is only going to be used for one (or a few) projects rather than being something commonly used. In the following, it will be discussed how library and include folders and library names are specified.

Visual Studio

Include and library paths:

External C++ packages are either installed by an installer (for example for many gnu programs), are provided by header and source files that should be compiled on the system (for example blitz) or are distributed as precompiled libraries along with the header files. In any case, to use the package in new programs their include and library paths must be specified. The external package generally has include, lib, and possibly bin (for executables) folder. These folders or their contents should become visible to the programs that want to use them. For sample the include and library files from GSL ( are shown below:


As mentioned there are three ways to link to this package in other programs:

    1. (Recommended for commonly used packages): Adding the contents of external lib, include, (and bin is applicable) folders to corresponding VC default folders. Figure below shows these folders on my VC installation:VC_HeaderLibraryFiles
    2. Adding them to additional VC directories as shown below. Similar to option above the libraries and include files will be accessible to all VC++ projects. VC_directories
    3. Only referring to include and library folders for one particular VC project. This option is often used to including user’s header files and linking to user’s library files. An example is shown below:



Library file names

Once the path of libraries are determined by any of the means above, one should specify which library names are used for a project. Below shows a sample inclusion of library names. The list is separated by space.



Update for newer versions of Visual Studio:

Global include and library directory: In newer versions of visual studio, the global include and library paths are set differently:

  • Under View -> Other Windows -> Property Manager.
  • Choose any of the projects in the solution under project manager window -> Open the project project.
  • Under Debug / Win32, Debug / x64, Release / win32, Release / x64 -> Choose the appropriate Cpp.*.user file.
  • Add global include and library directories under Common Properties -> VC++ Directories.

Other notes about newer versions of VC:

  • Project files are changed from vcproj to two files .vcxproj and .vcxproj.filter. The latter stores break-down of header and source files.
  • To prevent console from closing under exit command in the code follow (link):
    • Project -> YourProjectName Properties -> Configuration Properties -> Linker -> System. There in the field SubSystem use the drop-down to select Console (/SUBSYSTEM:CONSOLE)