How to Add Additional Libraries to Visual Studio Project

How to add additional libraries to Visual Studio project?

For Visual Studio you'll want to right click on your project in the solution explorer and then click on Properties.

Next open Configuration Properties and then Linker.

Now you want to add the folder you have the Allegro libraries in to Additional Library Directories,

Linker -> Input you'll add the actual library files under Additional Dependencies.

For the Header Files you'll also want to include their directories under C/C++ -> Additional Include Directories.

If there is a dll have a copy of it in your main project folder, and done.

I would recommend putting the Allegro files in the your project folder and then using local references in for the library and header directories.

Doing this will allow you to run the application on other computers without having to install Allergo on the other computer.

This was written for Visual Studio 2008. For 2010 it should be roughly the same.

How do I include libraries to a project in Visual Studio?

A library is added in two steps

  1. Adding headers path to the project
  2. Adding .lib reference

In the first step, you must specify in the project where library headers are header. Usually, the path is specified in the project properties -> C++ -> Additional include directories, and them including files with relative paths.

In the second step you must specify in properties->linker the path where libraries (.lib) are located and the name of the library. With this Visual Studio is able to link the project properly.

How to add static libraries to a Visual studio project

The tutorial you have provided refers to a case in which you create your own static library - in this case you may want to add it to your solution and thus make it an integral part of the solution; but I assume you are trying to add external libraries (not created by you, e.g. downloaded from the net) - that is why you got stuck.

On Property Pages, go to C/C++->General->Additional Include Directories and provide the path, where the header file of the library that you want to use is located.

Then go to Linker->General->Additional Library Directories and specify the path, where your .lib file is located.

Finally, go to Linker->Input->Additional Dependencies and add the name of the file containing your library together with its extension (e.g. example_library.lib).

That is all. Now you should be able to use the library. Remember to #include it in your files and use the right mode (release/debug) and the right version for your platform (x64/win32). You may have to repeat the steps given above both for release and debug versions of your app.

How do I add a library from another branch in VS

For more details about how to link the .lib, I suggest you could follow the following steps:

1,Add the path to the header file to the Additional Include Directories(property - >c/c++ -> General -> Additional Include Directories)

2,Add the path to the .lib file to the Additional Library Directories (property -> linker -> General -> Additional Library Directories)

3,Add the name of the .lib file with its extension to Additional Dependencies (property -> linker -> input -> Additional Dependencies)

You also need to make sure that you add the configuration properties to the correct build target and platform for your code.

For example:
Sample Image

Sample Image

I suggest you could select "All Platforms" for the platform and select "All Configurations" for the Configuration when changing the properties.

Sample Image

How to add C library to Visual Studio project

I just forgot to add the path to the generated .lib file (nfd.lib) to Projects->Properties->Linker->Input Additional Dependencies. After doing this, everything worked perfectly.

How to add all the folders under `/lib` to Additional Library Directories in visual studio 2019

Unfortunately, you couldn't add all the folders under /lib to “Additional Library Directories”. You could only add the library path one by one.



Related Topics



Leave a reply



Submit