How to add additional libraries to Visual Studio project?

331,007

Solution 1

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.

Solution 2

Add #pragma comment(lib, "Your library name here") to your source.

Solution 3

Without knowing your compiler, no one can give you specific, step by step instructions, but the basic procedure is as follows:

  1. Specify the path which should be searched in order to find the actual library (usually under Library Search Paths, Library Directories, etc. in the properties page)

  2. Under linker options, specify the actual name of the library. In VS, you would write Allegro.lib (or whatever it is), on Linux you usually just write Allegro (prefixes/suffixes are added automatically in most cases). This is usually under "Libraries->Input", just "Libraries", or something similar.

  3. Ensure that you have included the headers for the library and make sure that they can be found (similar process to that listed in step #1 and #2). If it is a static library, you should be good; if it's a DLL, you need to copy it in your project.

  4. Mash the build button.

Solution 4

This description is very vague. What did you try, and how did it fail.

To include a library with your project, you have to include it in the modules passed to the linker. The exact steps to do this depend on the tools you are using. That part has nothing to do with the OS.

Now, if you are successfully compiling the library into your app and it doesn't run, that COULD be related to the OS.

Share:
331,007
Saad Masood
Author by

Saad Masood

Full Stack Developer

Updated on July 08, 2022

Comments

  • Saad Masood
    Saad Masood almost 2 years

    Allergro is an open souce C++ addon library for graphics manipulation. How do I add this library to my compiler?

    The instructions don't work for me as I have Windows 7. I don't know if the OS matters. I have the Visual Studio Express Edition. The library is a .dll file. How do I add it to my projects?

  • Saad Masood
    Saad Masood over 13 years
    i got this zip file. i was told follow the instructions in the zip file. first you had to cmake. so i installed cmake but it didnt go accordingly.
  • Saad Masood
    Saad Masood over 13 years
    i use eclipse too. (MinGW). does it apply to that too?
  • Kuba Orlik
    Kuba Orlik almost 10 years
    That helped solve the problem in Visual Studio 2012. Thank you!
  • SexyBeast
    SexyBeast about 6 years
    Yep, works in VS 2017, if the lib is in a standard path, it is picked up automatically!
  • drescherjm
    drescherjm about 4 years
    i use eclipse too. (MinGW). does it apply to that too? Not exactly there will be similar instructions on a different IDE and toolchain but I would not expect the dialogs to be the same for a different IDE.
  • QuarterlyQuotaOfQuotes
    QuarterlyQuotaOfQuotes over 2 years
    Following the steps you suggested i am getting two errors: LNK1104 cannot open file 'chess.lib' MSB6006 "link.exe" exited with code 1104