You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Monday, August 4th 2008, 3:44pm

Library (DLL) issue

Hello!
My program is loading shared libraries (*.dll, *.so, etc) - that works fine - but I do need signal&slots and therefor I have to put Q_OBJECT into my class in the library. The linker does not like that, as the class is declared inside a extern "C" and Q_OBJECT uses template, pure C++ code.

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <QObject>
#include <QStringList>

extern "C" {
  class ModControl : public QObject {
	Q_OBJECT
	private:
  	bool isCreated;

	public:
  	ModControl();
  	~ModControl();

	public slots:
  	void send(const QStringList &strlArgs);
  };
}


When I'm removing Q_OBJECT, anything compiles and is linked properly.
What can I do?

2

Monday, August 4th 2008, 4:14pm

I don't understand why do declare class in extern "C" bloc
Nicolas

3

Monday, August 4th 2008, 4:23pm

Because if I would not, there will be a symbol resolving error - On module loading it says "undefined reference _ZY10ModControl" - putting the class into a extern "C" solves that problem.

4

Monday, August 4th 2008, 8:07pm

what is the library against which you link?
Nicolas