[Qt-interest] How to use my own static lib in another project?
xiaolei Shang
xiaolei.shang at esrtechnology.com
Tue May 19 18:33:41 CEST 2009
>
>
> 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
More information about the Qt-interest-old
mailing list