user10830252
user10830252

Reputation:

file not found error when trying to include id3lib header

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>

Upvotes: 0

Views: 375

Answers (1)

HMD
HMD

Reputation: 2226

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.

Upvotes: 1

Related Questions