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 filesTagLib.dll
andlibTagLib.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 thetaglib
directory. In your .pro file you do this by addingINCLUDEPATH+=/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
Wolfgang Plaschg
2010-10-05 08:52:55