Я пытаюсь работать над проектом, используя внешнюю библиотеку «taglib». Библиотека Taglib установлена в C: \ GitRoot \ taglib, а проект находится по другому пути. Я использую Eclipse.
Это исходный код проекта:
#include "mpegfile.h"#include "attachedpictureframe.h"#include "id3v2tag.h"
#include <iostream>
class ImageFile : public TagLib::File
{
public:
ImageFile(const char *file) : TagLib::File(file)
{
}
TagLib::ByteVector data()
{
return readBlock(length());
}private:
virtual TagLib::Tag *tag() const { return 0; }
virtual TagLib::AudioProperties *audioProperties() const { return 0; }
virtual bool save() { return false; }
};
int main(int argc, char *argv[])
{
if (argc != 3)
{
std::cout << "Usage: set cover <mp3> cover.jpg" << std::endl;
return 1;
}
TagLib::String fileName = argv[1];
TagLib::String fileType = fileName.substr(fileName.size() - 3).upper();
ImageFile imageFile(argv[2]);
if (fileType == "MP3")
{
TagLib::MPEG::File audioFile(argv[1]);
TagLib::ID3v2::Tag *tag = audioFile.ID3v2Tag(true);
TagLib::ID3v2::AttachedPictureFrame *frame = new TagLib::ID3v2::AttachedPictureFrame;
frame->setMimeType("image/jpeg");
frame->setPicture(imageFile.data());
tag->addFrame(frame);
audioFile.save();
}
else
{
std::cout << fileType << " is unsupported." << std::endl;
}
}
Я полагаю, что я правильно установил библиотеку, но когда я пытаюсь собрать проект, появляется эта ошибка:
15:09:17 **** Incremental Build of configuration Debug for project Mp3CoverTagger (external lib) ****
Info: Internal Builder is used for build
g++ -O0 -g3 -Wall -c -fmessage-length=0 -o Mp3CoverTagger.o "..\\Mp3CoverTagger.cpp"..\Mp3CoverTagger.cpp:1:22: fatal error: mpegfile.h: No such file or directory
#include "mpegfile.h"^
compilation terminated.
Я даже пытался поместить все файлы и заголовочные файлы в папку проекта, но это никогда не работает. На самом деле, в тот момент, когда я пытаюсь его построить, появляется сообщение об ошибке:
C:\Users\marco\eclipse-workspace\Mp3AutoCoverTagger>gcc Mp3AutoCoverTagger.cpp
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.text+0x2d): undefined reference to `std::cout'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.text+0x32): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.text+0x39): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.text+0x40): undefined reference to `std::ostream::operator<<(std::ostream& (*)(std::ostream&))'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.text+0x6a): undefined reference to `_imp___ZN6TagLib6StringC1EPKcNS0_4TypeE'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.text+0x79): undefined reference to `_imp___ZNK6TagLib6String4sizeEv'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.text+0x9a): undefined reference to `_imp___ZNK6TagLib6String6substrEjj'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.text+0xaf): undefined reference to `_imp___ZNK6TagLib6String5upperEv'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.text+0xbe): undefined reference to `_imp___ZN6TagLib6StringD1Ev'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.text+0xe9): undefined reference to `_imp___ZNK6TagLib6StringeqEPKc'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.text+0x10b): undefined reference to `_imp___ZN6TagLib8FileNameC1EPKc'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.text+0x133): undefined reference to `_imp___ZN6TagLib4MPEG4FileC1ENS_8FileNameEbNS_15AudioProperties9ReadStyleE'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.text+0x156): undefined reference to `_imp___ZN6TagLib4MPEG4File8ID3v2TagEb'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.text+0x16a): undefined reference to `operator new(unsigned int)'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.text+0x173): undefined reference to `_imp___ZN6TagLib5ID3v220AttachedPictureFrameC1Ev'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.text+0x191): undefined reference to `_imp___ZN6TagLib6StringC1EPKcNS0_4TypeE'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.text+0x1a6): undefined reference to `_imp___ZN6TagLib5ID3v220AttachedPictureFrame11setMimeTypeERKNS_6StringE'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.text+0x1b5): undefined reference to `_imp___ZN6TagLib6StringD1Ev'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.text+0x1da): undefined reference to `_imp___ZN6TagLib5ID3v220AttachedPictureFrame10setPictureERKNS_10ByteVectorE'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.text+0x1e9): undefined reference to `_imp___ZN6TagLib10ByteVectorD1Ev'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.text+0x1fb): undefined reference to `_imp___ZN6TagLib5ID3v23Tag8addFrameEPNS0_5FrameE'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.text+0x20d): undefined reference to `_imp___ZN6TagLib4MPEG4File4saveEv'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.text+0x21c): undefined reference to `_imp___ZN6TagLib4MPEG4FileD1Ev'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.text+0x22e): undefined reference to `std::cout'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.text+0x233): undefined reference to `_imp___ZlsRSoRKN6TagLib6StringE'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.text+0x245): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.text+0x24c): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.text+0x253): undefined reference to `std::ostream::operator<<(std::ostream& (*)(std::ostream&))'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.text+0x26a): undefined reference to `_imp___ZN6TagLib6StringD1Ev'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.text+0x276): undefined reference to `_imp___ZN6TagLib6StringD1Ev'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.text+0x28e): undefined reference to `_imp___ZN6TagLib6StringD1Ev'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.text+0x2b2): undefined reference to `operator delete(void*, unsigned int)'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.text+0x2c2): undefined reference to `_imp___ZN6TagLib6StringD1Ev'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.text+0x2d2): undefined reference to `_imp___ZN6TagLib10ByteVectorD1Ev'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.text+0x2e5): undefined reference to `_imp___ZN6TagLib4MPEG4FileD1Ev'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.text+0x303): undefined reference to `_imp___ZN6TagLib6StringD1Ev'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.text+0x313): undefined reference to `_imp___ZN6TagLib6StringD1Ev'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.text+0x33a): undefined reference to `std::ios_base::Init::~Init()'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.text+0x35b): undefined reference to `std::ios_base::Init::Init()'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.text$_ZN6TagLib8FileNameD1Ev[__ZN6TagLib8FileNameD1Ev]+0x12): undefined reference to `std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >::~basic_string()'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.text$_ZN6TagLib8FileNameD1Ev[__ZN6TagLib8FileNameD1Ev]+0x1c): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.text$_ZN9ImageFileC1EPKc[__ZN9ImageFileC1EPKc]+0x19): undefined reference to `_imp___ZN6TagLib8FileNameC1EPKc'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.text$_ZN9ImageFileC1EPKc[__ZN9ImageFileC1EPKc]+0x2b): undefined reference to `_imp___ZN6TagLib4FileC2ENS_8FileNameE'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.text$_ZN9ImageFile4dataEv[__ZN9ImageFile4dataEv]+0x13): undefined reference to `_imp___ZN6TagLib4File6lengthEv'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.text$_ZN9ImageFile4dataEv[__ZN9ImageFile4dataEv]+0x28): undefined reference to `_imp___ZN6TagLib4File9readBlockEm'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.text$_ZN9ImageFileD1Ev[__ZN9ImageFileD1Ev]+0x19): undefined reference to `_imp___ZN6TagLib4FileD2Ev'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.text$_ZN9ImageFileD0Ev[__ZN9ImageFileD0Ev]+0x22): undefined reference to `operator delete(void*, unsigned int)'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.rdata$_ZTI9ImageFile[__ZTI9ImageFile]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.rdata$_ZTIN6TagLib4FileE[__ZTIN6TagLib4FileE]+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.eh_frame$_ZN9ImageFileC1EPKc+0x13): undefined reference to `__gxx_personality_v0'
C:\Users\marco\AppData\Local\Temp\ccgsDHGg.o:Mp3AutoCoverTagger.cpp:(.eh_frame+0x13): undefined reference to `__gxx_personality_v0'
collect2.exe: error: ld returned 1 exit status
Мой вопрос: как правильно включить библиотеку taglib для сборки и компиляции программы? Как я могу исправить эту «неопределенную ссылку на» ошибку?
Спасибо
Задача ещё не решена.
Других решений пока нет …