views:

149

answers:

3

Hi all,

I am relatively new to C++ and need to use a library for the first time. I was hoping someone would be able to show me how to properly [ link to / include ] the library.

The library I want to use is the ID3 v3.8.8 that can be found here: http://id3lib.sourceforge.net/

I have downloaded the Windows binaries and now just need a way to link to the library.

Files downloaded: Debug/id3lib.dll, Debug/id3lib.lib, Debug/id3lib.exp, Release/id3lib.dll, Release/id3lib.lib, Release/id3lib.exp

I am using Visual Studio 2010.

Any help is greatly appreciated. Thanks in advance.

+2  A: 

Add id3lib.lib to your project, that should satisfy the linker and the resulting executable will depend on id3lib.dll.

Oleg Zhylin
+4  A: 

Before you can do any C++ development with this library you'll need the headers too which are in the id3lib-3.8.3.zip file. You have only downloaded the binaries which will let you run an application that needs those libraries but not re-compile it.

Troubadour
Following your advice, I have since downloaded id3lib-3.8.3.zip.Within that zip, I found a directory called "include". That "include" directory contained "id3.h" and an "id3" directory. I copied these two over into my project.Is that all I need to do? Can I disregard the binaries I downloaded?
Pooch
@Pooch: You need the headers for compilation and the libraries for linking so you need both to do a full build. Add the path to where you put "id3.h" and the "id3" folder as an include path in your project and, as @Oleg says, add id3lib.lib as a link dependency. I can't say _exactly_ how tdo this as I haven't used VS for years now.
Troubadour
U no need to copy include dir into your project. Copy all downloaded files into some dir at your hdd. Now need to configure your c++ project. Right mouse on project -> Propertice. Then c/c++ -> general -> additial include dirs (add path to your include dir where files were extracted) then linker -> general -> additional libs dir (add path with your libs choose first of all debug dir). As you have dll i think it is all your need. if i forgot smth i add.
den bardadym
Seems need to add id3lib.lib linker -> input -> additioanl dependencies (write id3lib.lib)
den bardadym
@den bardadym: Thanks for your help. I think I almost got it. I created a dir on my hdd with "Debug/id3lib.lib", "Debug/id3lib.dll", "id3/", and "id3.h". I set the additional include dirs to this folder. I Then set the linker additional libs to the "Debug/" dir within this folder. Lastly, I added id3lib.lib to the linkers additional dependencies. When I try to compile I am told that the id3lib.lib cannot be opened.
Pooch
The program now builds but a system error pops up saying "id3lib.dll" is missing from my comp. This .dll is in the Debug folder that I set the additional library include dirs to point at.
Pooch
+3  A: 

There are several steps, and many a pitfall. If you are a rank newbie at using C++ and VC++ in particular, every step is going to require some (gasp) reading of documentation or googling.

  • In VC++ 2010, use the Property Manager "C/C++ General / Additional Include Directories" section if necessary to tell the compiler how to find the header-files.
  • Use the Property Manager "C/C++/ Code Generation / Runtime Library" section if necessary to tell the compiler what version of the Microsoft C Runtime Library the library requires.
  • Use Property Manager "Linker / Input / Additional Dependencies " to specify the .lib file id3lib.lib.
  • Use Property Manager "Linker / General / Additional Library Directories" to tell the linker where to find .lib file.
  • If the dll id3lib.dll is not in the directory where you will start your program, open a Microsoft Explorer window, and right-click on "My Computer." Select "Properties/Advanced/Environment Variables", and edit the user-variable PATH to contain the path of the directory that contains the dll. Be very careful doing this. Before you change it, copy the value that's there originally and save it to a text file, in case you mess up and need to restore it. If you get it wrong, other programs can fail to start.

Good luck.

Jive Dadson
Thanks everyone for your help. I recognize the pitfalls involved and I appreciate your help despite this fact. The information you provided should be enough for me to make some progress on my own as opposed to aimlessly changing settings.
Pooch