[Qt-interest] How to use my own static lib in another project?

Yao Huiji spideryao at gmail.com
Tue May 19 12:58:07 CEST 2009


hi,
I'm  a newbie here , and my english is not good ,  so if you don't
understand my following words,pls let me know , and I'll try my best to
explain it.

I've written a static lib using qt 4.4.2 + vs 2008 ,  it can be builded
successfully, the .h file like this:

#ifndef SETTINGS_H
> #define SETTINGS_H
>
> #include <QObject>
> #include <QString>
>
> class Q_DECL_EXPORT Settings : public QObject
> {
>     Q_OBJECT
>
> public:
>     static Settings* Current();
>     ~Settings();
>     const QString GetConfigFileName();
>     void SetConfigFileName(const QString*);
> private:
>     static Settings* _current;
>     QString _configFileName;
>     Settings(QObject *parent);
> };
>
> #endif // SETTINGS_H


but when I try to use this lib in another qt project just using the simple
statement "Settings::Current();" , the errors occured:


Error    1    error LNK2001: unresolved external symbol "public: static
> struct QMetaObject const Settings::staticMetaObject"
> (?staticMetaObject at Settings@@2UQMetaObject@@B)    main.obj    Test
>
> Error    2    error LNK2019: unresolved external symbol "public: static
> class Settings * __cdecl Settings::Current(void)" (?Current at Settings
> @@SAPAV1 at XZ) referenced in function _main    main.obj    Test
>
> Error    3    fatal error LNK1120: 2 unresolved externals
> E:\learnspace\QtPhotoPlayer\Debug\Test.exe    Test


anyone can help me? thank you!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090519/5fe07d25/attachment.html 


More information about the Qt-interest-old mailing list