[Qt-interest] How to use my own static lib in another project?
Yao Huiji
spideryao at gmail.com
Wed May 20 08:14:44 CEST 2009
thank you , but it's already in the "qglobal.h",and I have checked my
"Preprocessor Definitions", they are all defined.
*settings_global.h*:
> #ifndef SETTINGS_GLOBAL_H
> #define SETTINGS_GLOBAL_H
>
> #include <Qt/qglobal.h>
>
> #ifdef SETTINGS_LIB
> # define SETTINGS_EXPORT Q_DECL_EXPORT
> #else
> # define SETTINGS_EXPORT Q_DECL_IMPORT
> #endif
>
> #endif // SETTINGS_GLOBAL_H
>
*Preprocessor Definitions:*
> UNICODE,WIN32,QT_THREAD_SUPPORT,QT_CORE_LIB,QT_XML_LIB,UTILITY_LIB
>
2009/5/20 xiaolei Shang <xiaolei.shang at esrtechnology.com>
>
>
>>
>> thank you for your reply.
>>
>> I edit my code , incude the "settings_global.h" file generated by vs qt
>> project template, and add "SETTINGS_LIB" to "DEFINES" section
>>
>> #ifdef SETTINGS_LIB
>> # define SETTINGS_EXPORT Q_DECL_EXPORT
>> #else
>> # define SETTINGS_EXPORT Q_DECL_IMPORT
>> #endif
>>
>>
>> but it still does not work when I use the lib file in another project,
>> the error message is :
>>
>> error LNK2019: unresolved external symbol "__declspec(dllimport)
>> public: __declspec(dllimport) public: __thiscall
>> Settings::Settings(void)" (__imp_??0Settings@@QAE at XZ) referenced
>> in function _main
>>
>> can you help me ? ;-(
>>
> Hi:
>
> In your "settings_global.h", before the code you mentioned above, to do:
>
> #ifdef WIN32
> #define Q_DECL_IMPORT __declspec(dllimport)
> #define Q_DECL_EXPORT __declspec(dllexport)
>
> In other classes which you wish to be exported, to use SETTINGS_EXPORT
> rather than Q_DECL_EXPORT. Take your case as example:
>
> #include "settings_global.h"
> class SETTINGS_EXPORT Settings : public QObject
> {
> ...
> };
>
> Hope it helps.
>
> Cheers
>
> Xiaolei
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090520/92cb8ff5/attachment.html
More information about the Qt-interest-old
mailing list