0

I downloaded id3lib and placed the directory in my main.cpp directory but both g++ and visual studio give file/directory not founds and "undefined" errors

Here is my main.cpp:

#include <iostream>
#include <id3lib-3.8.3/include/id3/tag.h>
int main() { std::cout << "hi"; }

g++ main.cpp gives:

main.cpp:2:46: fatal error: id3lib-3.8.3/include/id3/tag.h: No such file or 
directory
 #include <id3lib-3.8.3/include/id3/tag.h>

if I use "" instead of <>, i get this error:

id3lib-3.8.3/include/id3/tag.h:32:30: fatal error: id3/id3lib_frame.h: No 
such file or directory
 #include <id3/id3lib_frame.h>

1 Answers1

1

It's not enough to put it beside your main file. As you can see in your first approach when you used #include with <> it can't find it, that's because (copied from here) :

For #include <filename> the preprocessor searches in an implementation dependent manner, normally in search directories pre-designated by the compiler/IDE. This method is normally used to include standard library header files.

You didn't tell your compiler where to look for id3lib-3.8.3/include/id3/tag.h so <> will not work for you.

Then you tried "". it found id3lib-3.8.3/include/id3/tag.h but in the tag.h there is #include <id3/id3lib_frame.h>, So back to problem with first approach, right?

What you need to do is that you need to tell your compiler/IDE where to look for these files. In visual studio click right on your project file, then properties->C/C++->General->Additional Include Directories and add the include library ($(ProjectDir)id3lib-3.8.3/include/ or maybe $(SolutionDir)id3lib-3.8.3/include/) to it. Then your first approach should work fine.

HMD
  • 2,202
  • 6
  • 24
  • 37
  • I added the include directory as you said, and the include line is now #include , but there still is a whole list of errors on VS. The first error is "incomplete type is not allowed" on the file field.h –  Dec 29 '18 at 06:53
  • @J.W That's another thing, using libraries in c++ can be difficult task sometimes, You need to take care of every dependency. I don't know about `id3lib` but almost every library has it's *how to use/compile* document, read it carefully. – HMD Dec 29 '18 at 06:57
  • id3lib says that just #include would work (link: http://id3lib.sourceforge.net/api/index.html). This is weird because I got it to work on g++ the first time around. I moved the directory to a separate drive and updated windows since that time and now it doesn't work. –  Dec 29 '18 at 07:13