2017-08-04 28 views
1

除了我以前的Q在C++项目中安装和使用TagLib

我试过很多sources为了找到正确的方法来安装C++的taglib库并在我的项目中使用它。

我包括路径

#include <taglib/tag.h> 

我想包括刚才

#include <taglib> 

但即使寿/usr/include/taglib存在,它没有工作。

我编译使用

g++ -Wall -pedantic -std=c++11 -ltaglib main.cpp -I taglib-1.11.1/toolkit 

还演示从网站

TagLib::FileRef f("Latex Solar Beef.mp3"); 
TagLib::String artist = f.tag()->artist(); // artist == "Frank Zappa" 

我的项目抛出

error: ‘FileRef’ is not a member of ‘TagLib’ TagLib::FileRef f("Latex Solar Beef.mp3"); ^main.cpp:5:18: error: expected ‘;’ before ‘f’ TagLib::FileRef f("Latex Solar Beef.mp3"); ^main.cpp:6:25: error: ‘f’ was not declared in this scope TagLib::String artist = f.tag()->artist(); // artist == "Frank Zappa"

当我添加#include <taglib/fileref.h>

它抛出

main.cpp:(.text.startup+0x48): undefined reference to TagLib::FileRef::FileRef(char const*, bool, TagLib::AudioProperties::ReadStyle)' main.cpp:(.text.startup+0x50): undefined reference to TagLib::FileRef::tag() const' main.cpp:(.text.startup+0x68): undefined reference to TagLib::String::~String()' main.cpp:(.text.startup+0x70): undefined reference to TagLib::FileRef::~FileRef()' main.cpp:(.text.startup+0x83): undefined reference to `TagLib::FileRef::~FileRef()' collect2: error: ld returned 1 exit status

什么是安装和使用的正确方法TagLib

+0

这是整个错误输出 – Darlyn

+0

我不知道什么是错在这里,但它仍然抱怨,如果你分裂声明如..标签库:: FileRef f = TagLib :: FileRef(“Latex Solar Beef.mp3”); – hoodaticus

+0

@hoodaticus是它仍然抱怨 – Darlyn

回答

0

尝试加入这个选项在释放模式编译:

-O3 
+0

g ++ -Wall -pedantic -std = C++ 11 -03 -ltaglib main.cpp -I taglib-1.11.1/toolkit? “无法识别的命令-03” – Darlyn

+0

@trolkura“大写O”,而不是零 –

+0

我的坏...仍然没有工作tho – Darlyn