[Qt-interest] Splitting library?

Hong Jiang kmldqj at gmail.com
Wed Feb 10 19:59:22 CET 2010


I assume you first produce a library file for your library and then link it
with some other files? What's the commandline you use with your
linker/compiler?

On Wed, Feb 10, 2010 at 10:48 AM, Anatoly Burakov <
burakov.anatoly at googlemail.com> wrote:

> Hong Jiang wrote:
>
>> Are you sure it is a compiler error? Or is it a linker error?
>>
>> --Hong
>>
>> On Wed, Feb 10, 2010 at 10:34 AM, Anatoly Burakov <
>> burakov.anatoly at googlemail.com <mailto:burakov.anatoly at googlemail.com>>
>> wrote:
>>
>>    Hi all
>>
>>    This question is not exactly related to QT, more of a general C++
>>    question. Sorry for maybe a n00b-type problem but everyone has to
>>    start somewhere :-)
>>
>>    I have made a small class library for use within a family of
>>    applications. I have separated it into several header/source files
>>    one per class, and one "root" header file which includes all these
>>    "child" header files. This whole library uses a separate
>>    namespace. On its own the library compiles OK, but whenever i try
>>    to include the "root" library header into the other project and
>>    try to use classes from the library - compiler can't find them
>>    (although IDE itself can - it lists all member functions when
>>    autocompleting code etc.) and gives an error of "undefined
>>    reference to Namespace::ClassName()::ClassName()". Am i missing
>>    something? By the way, the library worked fine when it was not
>>    separated into several files, so there must be something i don't
>>    understand about how headers work...
>>
>>    The structure of the root header file is following:
>>    -------------------------
>>
>>    #include <math.h>
>>
>>    namespace Namespace {
>>      // classes pre-declarations follow here e.g.
>>      class childOne;
>>      class childTwo;
>>
>>      // helper function header used throughout the class library e.g.
>>      double hlpFunc(const double &value);
>>
>>      // helper enum used throughout the class library e.g.
>>      enum hlpEnum {
>>         varA = 0, varB = 5, varC = 10
>>         };
>>    }
>>
>>    // includes for child classes' headers e.g.
>>    #include "childone.h"
>>    #include "childtwo.h"
>>
>>    -------------------------
>>
>>    Best regards,
>>    Anatoly
>>
>>    _______________________________________________
>>    Qt-interest mailing list
>>    Qt-interest at trolltech.com <mailto:Qt-interest at trolltech.com>
>>
>>    http://lists.trolltech.com/mailman/listinfo/qt-interest
>>
>>
>>  Well, yes, it is a linking error - but still it is an error, and i would
> like to know how to fix it.
>
> Anatoly
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100210/6fd7c5bb/attachment.html 


More information about the Qt-interest-old mailing list