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>
4

1 回答 1

0

将它放在主文件旁边是不够的。正如您在第一种方法中看到的那样,当您使用#include<>时找不到它,那是因为(从这里复制):

对于#include <filename>预处理器以依赖于实现的方式进行搜索,通常在编译器/IDE 预先指定的搜索目录中。此方法通常用于包含标准库头文件。

你没有告诉你的编译器在哪里寻找id3lib-3.8.3/include/id3/tag.h所以<>对你不起作用。

然后你尝试了""。它找到id3lib-3.8.3/include/id3/tag.h了,但在tag.h那里#include <id3/id3lib_frame.h>,所以回到第一种方法的问题,对吧?

您需要做的是您需要告诉您的编译器/IDE 在哪里查找这些文件。在 Visual Studio 中,右键单击您的项目文件,然后单击 properties->C/C++->General->Additional Include Directories 并将包含库($(ProjectDir)id3lib-3.8.3/include/或可能$(SolutionDir)id3lib-3.8.3/include/)添加到其中。那么你的第一种方法应该可以正常工作。

于 2018-12-29T06:14:14.097 回答