[Qt-interest] how to resolve this moc linker error
Matthias Pospiech
matthias.pospiech at gmx.de
Tue Jul 20 08:08:32 CEST 2010
Malyushytsky, Alex schrieb:
> I would double check that you built mentioned dll with Q_OBJECT macro defined there.
> Also it is probably worth to verify that your import / export was defined properly.
>
I am familiar with this import/export code for msvc, but to check I post
it now here.
QCameraImage is not specific to my project (it is used in now 2
projects, to share the code).
That itsself is troublesome if one wants to use it in a library.
QCameraImage.h is thus importet with svn:externals.
---- QCameraImage.h -->
#ifndef CAMERAIMAGE_H_
#define CAMERAIMAGE_H_
// IMPORTANT: You must add an QCameraImage.cpp file with such content
// #include "<Global Definitions File>.h"
// #include "QCameraImage.h"
#include <windows.h>
#ifdef QSMXCAMERA_EXPORT
#define QCAMERAIMAGEEXPORT QSMXCAMERA_EXPORT
#else
#ifdef QCAMERA_EXPORT
#define QCAMERAIMAGEEXPORT QCAMERA_EXPORT
#else
#define QCAMERAIMAGEEXPORT
#endif
#endif
#include <QtGui/QWidget>
...
class QCAMERAIMAGEEXPORT QCameraImage : public QWidget
{
//Q_OBJECT
public:
QCameraImage(QWidget* parent = 0, Qt::WFlags flags = 0)
...
<----------------------------
To make it compile I require a local QCameraImage.cpp in each project
(which is only required for msvc)
---- QCameraImage.cpp -->
#include "QCameraSMXGlobal.h"
#include "QCameraImage.h"
<----------------------------
The QCameraWidget class itsself is very simple, here it is identical
with QCameraImage
---- QCameraWidget.h -->
#ifndef QCAMERAWIDGET_H
#define QCAMERAWIDGET_H
#include "QCameraGlobal.h"
#include "QCameraImage.h"
class QCAMERA_EXPORT QCameraWidget : public QCameraImage
{
Q_OBJECT
public:
explicit QCameraWidget(QWidget *parent = 0);
};
#endif // QCAMERAWIDGET_H
<----------------------------
---- QCameraWidget.cpp -->
#include "qcamerawidget.h"
QCameraWidget::QCameraWidget(QWidget *parent) :
QCameraImage(parent)
{
}
<----------------------------
As I said, QCameraWidget is then used in the ui of MainWindow.cpp
The Import/Export Definitions are this
---- QCameraGlobal.h -->
#ifndef QCAMERA_GLOBAL_H
#define QCAMERA_GLOBAL_H
#include <QtGlobal>
#if defined(Q_WS_WIN)
#ifdef UEYECAMERA_DLL
#if defined(UEYECAMERA_NODLL) // Do not create a DLL library
#define QCAMERA_EXPORT
#else
#if defined(UEYECAMERA_MAKEDLL) // create a DLL library
#define QCAMERA_EXPORT __declspec(dllexport)
#else // use a DLL library
#define QCAMERA_EXPORT __declspec(dllimport)
#endif
#endif
#endif // UEYECAMERA_DLL
#endif // Q_WS_WIN
#ifndef QCAMERA_EXPORT
#define QCAMERA_EXPORT
#endif
#endif // QCAMERA_GLOBAL_H
<----------------------------
I think that is mainly what you were suggesting?
Matthias
More information about the Qt-interest-old
mailing list