Nominate our 2022 Qt Champions!

Compiling taglib on Qt

  • Hi I have the following program in Qt running on Fedora 9. I am using Taglib library to extract album cover.

    @TagLib::MPEG::File mpegFile(fileName,true,TagLib::AudioProperties::Average);
    TagLib::ID3v2::Tag *id3v2tag = mpegFile.ID3v2Tag(true);
    TagLib::ID3v2::FrameList Frame ;
    TagLib::ID3v2::AttachedPictureFrame *PicFrame ;
    void *RetImage = NULL, *SrcImage ;
    unsigned long Size ;

                     FILE *jpegFile;
                     fopen ("&jpegFile;.jpg","wb");
                       if ( id3v2tag )
                         // picture frame
                         Frame = id3v2tag->frameListMap()["IdPicture"] ;
                         if (!Frame.isEmpty() )
                           // find cover art
                     for(TagLib::ID3v2::FrameList::ConstIterator it = Frame.begin(); it !=
                     Frame.end(); ++it)
                       PicFrame = (TagLib::ID3v2::AttachedPictureFrame *)(*it) ;
                             if ( PicFrame->type() ==
                               // extract image (in it's compressed form)
                               Size = PicFrame->picture().size() ;
                               SrcImage = malloc ( Size ) ;
                               if ( SrcImage )
                                 memcpy ( SrcImage, PicFrame->picture().data(), Size ) ;
                     fwrite(SrcImage,Size,1, jpegFile);
                                 free( SrcImage ) ;
                               if ( RetImage )
                                 break ;

    I am getting the following linking errors. Can anybody tell me how do I resolve it.

    • error: undefined reference to TagLib::MPEG::File::File(char const*, bool, TagLib::AudioProperties::ReadStyle)' error: undefined reference toTagLib::MPEG::File::ID3v2Tag(bool)'
      error: undefined reference to TagLib::ByteVector::ByteVector(char const*)' error: undefined reference toTagLib::ID3v2::Tag::frameListMap() const'
      error: undefined reference to `TagLib::ByteVector::~ByteVector()'

  • Hi sruthihsr, your code are not easy to identify where is the functon entry, and seems miss "}" somewhere, can you make it more readable?
    Do you link the lib when you use TagLib? (I think that's the most possible reason for undefined reference)
    Btw, You can use "using" keywork to simplify the namesapce

  • Thanks,
    It worked for me on addition of -ltag -ltag_c to LIBS in make file

Log in to reply