staticMetaObjectExtraData”: 不允许 dllimport 静态数据成员的定义
testManage.h
#ifndef TEST_MANAGE
#define TEST_MANAGE
#ifdef MYLIBDLL
#define MYLIBDLL_A _declspec(dllimport)
#else
#define MYLIBDLL_A _declspec(dllexport)
#endif
#endif
//////////////////
testdll1.h
#ifndef TESTDLL1_H
#define TESTDLL1_H
#include <QtGui/QMainWindow>
#include "ui_testdll1.h"
#include "testManage.h"
#include <string>
#include <iostream>
using namespace std;
class MYLIBDLL_A testDll1 : public QMainWindow
{
Q_OBJECT
public:
testDll1(QWidget *parent = 0, Qt::WFlags flags = 0);
~testDll1();
void printMe();
private:
Ui::testDll1Class ui;
};
#endif
////////////////////////////////
testdll.cpp
#include "testdll1.h"
testDll1::testDll1(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
{
ui.setupUi(this);
}
testDll1::~testDll1()
{
}
void testDll1::printMe()
{
std::cout << "hello" << endl;
}
生成的时候,提示错误:
错误 5 error C2491: “testDll1::staticMetaObjectExtraData”: 不允许 dllimport 静态数据成员 的定义 E:\Projects\testDll1\testDll1\GeneratedFiles\Debug\moc_testdll1.cpp 47
错误 7 error C2491: “testDll1::staticMetaObject”: 不允许 dllimport 静态数据成员 的定义 E:\Projects\testDll1\testDll1\GeneratedFiles\Debug\moc_testdll1.cpp 51
我用的平台是vs2010. 好奇怪的问题啊。求同志们踊跃发言。哈哈哈