Compiling TagLib into Qt C++ Project on Windows

淺唱寂寞╮ 提交于 2019-11-29 08:46:21

For future reference, check out this post. I've outlined how I compiled TagLib through Windows 7 QtCreator.

If you're new to C++ programming there are several issues you have to grasp to accomplish your task:

  • Source files (*.cpp) contain the actual source code, while header files (*.h) just declare what's inside a source file. You have to include all headers in your source files that use classes/functions/variables from other source files.
  • You need to understand how the preprocessor works. AFAIK C# does not have one. The wikipedia article should give you a good overview: http://en.wikipedia.org/wiki/C_preprocessor
  • Assuming you want to use TagLib as a dynamic library you have to create a Qt project for just building TagLib as a .dll (.pro file directives TEMPLATE=lib, CONFIG+=dll)
  • If you want to create a dynamic library out of a source files you have to mark the functions you want to use later as exportable. In TagLib this is done by defining the preprocessor macro MAKE_TAGLIB_LIB (in your taglib .pro file: DEFINES+=MAKE_TAGLIB_LIB)
  • Then you have to build the dynamic library (in your pro file: TEMPLATE=lib, then adding all sources and headers of taglib). When you use gcc this will result in two files TagLib.dll and libTagLib.a.
  • When building your application you have to include the header files of TagLib in your source and tell the compiler about the library (in your .pro file: LIBS+=libTagLib.a)
  • In your code you simply include the header file from your library. Let's say you want to use TagLib::Tag in your source file, then you must #include <taglib/tag.h>; You also have to tell the compiler (to be precise: the preprocessor) where it can find the taglib directory. In your .pro file you do this by adding INCLUDEPATH+=/path/to/taglib.

These are the big points and are not an in-depth explanation of what you have to do. Please ask more detailed questions if you have a problem when realizing this points.

For more information look at the qmake manual: http://doc.trolltech.com/4.6/qmake-variable-reference.html#libs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!