2017-08-04 26 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