1

I am a begginer C programmer, and recently I have run into a problem that I was unable to solve.

I am struggling to install and use this library (wich is for id3 tag editing in mp3 files).

I have already used other .h files in other codes, just by pasting the file in my /include directory.

When I do this and put the #include <id3v2lib.h> everything is just fine, but when i call a function from within this library the compiler says it is a "undefined reference" (I think it is caused because I didn't installed the library propperly).

On the GitHub page it is said that you would need to use cmake, but I am struggling with that too.

I'm on windows 10x64, using Dev-cpp as my IDE, and gcc as the compiler.

Can someone help me install this library? Thanks in advance.

  • You will have to link the library to use functions from the library. – MikeCAT Jun 22 '16 at 14:35
  • You probably need to add `-lid3v2` (meaning "use code in the library id3v2") to the end of the compilation command. The compiler should be smart enough to find the library if it is properly installed. The complete compilation command would be something like `gcc -std=c99 -pedantic -Wall -o test.exe test.c -lid3v2` – pmg Jun 22 '16 at 14:38
  • the .h file is NOT a library; it just contains the API for the library (it specifies the signature of all publicly available methods, structs, and macros in the library. You need to specify the library when you link the program. As @pmg mentioned, uses `-lid3vlib` in the link command. You may need to include '-Lxxx` before that if the library is not in the standard system library path, where 'xxx' is the directory where you saved the library. – FredK Jun 22 '16 at 14:41

1 Answers1

0

Your IDE do not see the C-files (files with the ending .c) of the id3v2lib. This files reside in the src directory of the id3v2lib.

The beginners approach is to add those C-files.

The more advanced approach is to build the library and tell gcc the directory where the file libid3v2.a resides using the compilerflag -L.

Example: Lets assume that D:\foo\libid3v2.a is the compiled lib, than you have to add the following compiler option: -LD:\foo -lid3v2.

This behavior should be supported by your IDE.

cforler
  • 179
  • 1
  • 7
  • Thanks, I compiled the lib into a .a file, but added the `-static-libgcc id3v2lib.a` command instead, as -L wasn't working. – Pietro Carrara Jun 22 '16 at 22:57