I am working on a C++ project in Qt Creator (on OS X), and I want to use TagLib. After much research online, I'm struggling to figure out how to get to a point where I can use the TagLib library in my project.
So far I have:
taglib-1.11.1.tar
and unarchived the contents.Any help with this would be much appreciated, thanks.
Edit:
When I add the external library, the following is added to my .pro file:
win32:CONFIG(release, debug|release): LIBS += - L$$PWD/../../../Libraries/taglib-1.11.1/taglib/release/ -ltag
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../Libraries/taglib-1.11.1/taglib/debug/ -ltag
else:mac: LIBS += -F$$PWD/../../../Libraries/taglib-1.11.1/taglib/ -framework tag
else:unix: LIBS += -L$$PWD/../../../Libraries/taglib-1.11.1/taglib/ -ltag
INCLUDEPATH += $$PWD/../../../Libraries/taglib-1.11.1/taglib
DEPENDPATH += $$PWD/../../../Libraries/taglib-1.11.1/taglib
I then run qmake, and the project builds & runs fine. However, if I attempt to do something like #include <tag.h>
, I get an error. For this example, it says 'tstring.h' file not found #include "tstring.h"
. Then, when I delete the error line, it gives a different error when I run it framework not found tag
linker command failed with exit code 1 (use -v to see invocation)
.
Edit:
code in .pro changed to:
#win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../Libraries/taglib-1.11.1/taglib/release/ -ltag
#else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../Libraries/taglib-1.11.1/taglib/debug/ -ltag
LIBS += -F$$PWD/../../../Libraries/taglib-1.11.1/taglib/ -ltag
#else:unix: LIBS += -L$$PWD/../../../Libraries/taglib-1.11.1/taglib/ -ltag
INCLUDEPATH += $$PWD/../../../Libraries/taglib-1.11.1/taglib
DEPENDPATH += $$PWD/../../../Libraries/taglib-1.11.1/taglib
Now I get the error library not found for -ltag
.
Here is an image of the files under ../Libraries/taglib-1.11.1
and the options I used in CMake link.
Edit:
I installed in it using the following:
cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_BUILD_TYPE=Release
make
sudo make install
Now the directory of files in the library looks like the following. Then I re-added the external directory in Qt. So now my .pro file contains:
LIBS += -L$$PWD/../../../Libraries/taglib-1.11.1/taglib/ -ltag
INCLUDEPATH += $$PWD/../../../Libraries/taglib-1.11.1/taglib
DEPENDPATH += $$PWD/../../../Libraries/taglib-1.11.1/taglib
PRE_TARGETDEPS += $$PWD/../../../Libraries/taglib-1.11.1/taglib/libtag.a
Now it runs fine, unless I try to do something like #include <tag.h>
and it gives the error 'tstring.h' file not found
.
If you only build taglib without installing it.
You should have something along the lines of:
INCLUDEPATH += \
/path/to/taglib_source/taglib \
/path/to/taglib_source/taglib/toolkit \
/path/to/taglib_builddir/
LIBS += \
-L/path/to/taglib_builddir/taglib \
-ltag
If you installed taglib using the defaults:
INCLUDEPATH += \
/usr/local/include/taglib
LIBS += \
-L/usr/local/lib \
-ltag