PDA

View Full Version : Loading a TabLib .a File into project



Atais
8th February 2011, 18:02
Hi
So far I've been googling for 5h and still I can't make this simple program work.
I want to manage MP3 tags. I have chosen TagLib as my library to edit files.

So what is what I know so far.
I have managed to obtain .dll and .a file (so I could even choose) from here:
http://www.joelverhagen.com/blog/2010/11/how-to-compile-taglib-on-windows/

and I have the include folder from TagLib homepage:
http://developer.kde.org/~wheeler/taglib.html

so now what I think i should do is edit my .pro file:
INCLUDEPATH += D:\Qt\taglib\include\
LIBS += D:\Qt\taglib

so in include I have headers and stuff of TagLib and in taglib i got the .dll and .a file.

Now in mainwindow.cpp I did:
#include <tag.h> so i should be able to use the whole Library, but... i got a lot of errors and I dont understand why.

I think that if i manage to solve first two ii will deal with the rest:

http://s536.photobucket.com/albums/ff323/d2ata/?action=view&current=first.png
this one ilustrates that i think i should define how i am going to include (dynamic or static) library. But i dont understand why the include has an unbuild cmake file and simply changing extension is not working properly.

http://s536.photobucket.com/albums/ff323/d2ata/?action=view&current=second.png
and this one shows that taglib is using fstring but according to compiler my computer is not... and I really dont know how to solve this one cos I simply miss another library.


Would id3lib be easier to use?
I just need to read and write tags, dont care about speed and stuff.
But still i cant find any examples of using this libs or even how to properly load them into project ; (

Thanks in advance.

ChrisW67
8th February 2011, 22:27
Please do not link to external resources in your posts; upload the images here so that they do not disappear leaving a useless post here. Feel free to edit your post to fix it.

Your problem is not taglib, so switching libraries will not help you. Your images show that include files are not being found. That is, your INCLUDEPATH is wrong. Your LIBS variable is not in play with the errors you show but it is also incorrect.

The necessary qmake variables would be something like:


TAGLIBDIR = D:/taglib-1.6.3
INCLUDEPATH += $$(TAGLIBDIR)/include
LIBS += -L$$(TAGLIBDIR)/lib -ltag
where d:/taglib-1.6.3 is where you installed taglib (adjust as required). Have a look in that directory to see that the header and library files are there.

Atais
8th February 2011, 23:36
Yes u were a bit right.

So i solved one problem to encounter another/
Well unfortunately I moved to Ubuntu because i found it a bit easier to install the libs etc.

What I did so far:


Download TagLib.
cd /taglib
./configure
make
sudo make install


Open new project in QT.
TAGLIBDIR = /home/atais/Desktop/taglib-1.6.3
INCLUDEPATH += $$(TAGLIBDIR)/taglib

no need for library??
Because I didnt build any??

But now when I added this to project I can use:
#include <taglib/tag.h> etc.
QT is even telling me the ending, so it finds it somehow correct, but still...

as u can see on prtscn.. the classes are not working correctly... and i dont undestand why now :(


Its the same when I am using their examples so... i think there must still be some declaration problems :/

ChrisW67
9th February 2011, 02:05
What I did so far:
Download TagLib.
cd /taglib
./configure
make
sudo make install

Ok. A default build and install. So, the configure prefix was /usr/local.



Open new project in QT.
TAGLIBDIR = /home/atais/Desktop/taglib-1.6.3
INCLUDEPATH += $$(TAGLIBDIR)/taglib

Taglib has been installed into /usr/local not /home/atais/Desktop/taglib-1.6.3. My original response is still correct with:


TAGLIBDIR = /usr/local




no need for library??
Because I didnt build any??

Why do you say that? You clearly built and installed the library.

Atais
9th February 2011, 10:23
omfg I got confused in all of this :P
but now I understand.

TAGLIBDIR = /usr/local
INCLUDEPATH += $$(TAGLIBDIR)/include
LIBS += -L$$(TAGLIBDIR)/lib -ltag

and it now works... perfectly.

Could u just tell me, now if I want to move this app to Windows, specially without installed taglib and QT Creator, I know I should look for some .dll files from QT like QTGui etc...

what about taglib?
in /usr/local/lib there are some files:

libtag_c.la
libtag_c.so
libtag_c.so.0
libtag_c.so.0.0.0
libtag.la
libtag.so
libtag.so.1
libtag.so.1.9.0

but i am quite sure they wont work, i need dll or sth like that. So what should i do :)?
and how could I build the app so I would work on Windows?

ok I understand it all by now.
I clearly need to build taglib under windows so I would have header files as on linux in /include
and I would obtain a proper DLL/a file as well. (am I wrong?)
If not the only problem I have is with building this app since I see I've done it all wrong :P.

Atais
9th February 2011, 16:44
Ok i think I got it... the other way actually.
I know what I've done wrong but still I can't compile taglib on windows. Just impossible for me.

I am giving a try to id3lib but to do so I need to download Visual Studio and msdnaa is very slow this days.
Hopefully i have understood how it works... and it took me 2 days :D
I think I start a blog or sth, so I could post positive effects somewhere and others could use it as help.
Thanks!

ChrisW67
9th February 2011, 22:22
On Windows you use CMake rather than configure to produce the Makefile. The install location is the CMAKE_INSTALL_PREFIX variable you can set in CMake (Install CMake Item 6 in the instruction you linked). The build and install are the same after that (i.e. make && make install ).

You then set TAGLIBDIR in your PRO file to the same value as the CMAKE_INSTALL_PREFIX and you should be good to go. You may need to wrap the path in quotes if it contains spaces as the example does:


TAGLIBDIR = $$quote(C:/Program Files/taglib)
INCLUDEPATH += $$quote( $${TAGLIBDIR}/include )
LIBS += -L$$quote($${TAGLIBDIR}/lib) -ltag

Please note that I have changed some of the parentheses () to braces {}... I had the wrong ones in my earlier post.

You may find you need:


INCLUDEPATH += $$quote( $${TAGLIBDIR}/include/taglib )

if your source goes:


#include <tag.h>
// as some of the examples do, rather than
#include <taglib/tag.h>