PDA

View Full Version : [Qt 4.4 + Eclipse] My QT lib makes me crash ( 0xc0000005 )



bunjee
13th August 2008, 14:32
Hey there,

I'm starting a new project built around the following approach:

LIB_ITEM - A QT library of widgets.
CORE_PROGRAM - The Core of the program using that Qt library.

* Inside of my LIB_ITEM I have a widget declared as qtBox, it does nothing except having a ctor + dtor.
* Inside of my CORE_PROGRAM I declare a widget which inherits of qtBox.

Now, for some reason when running my CORE_PROGRAM :

-> If I provide the lib DLL, I get a crash before the main is even reached.
-> If I don't provide the lib DLL, I get a symbol's missing crash.
-> If I don't inherit and use the lib, it doesn't crash.

What bugs me is the fact that even if I don't do anything in my main, the program still crashes when linked to my LIB_ITEM.

Any idea ?

bunjee
13th August 2008, 17:24
I tried to run the app out of the Eclipse environment,
I'm getting this on Windows :

Application error:
The application cannot execute ( 0xc0000005 )

and then a Segfault.

bunjee
13th August 2008, 18:46
Solved.

This is a Windows specific issue.
Each DLL Classes needs to exported during the DLL build.
Each DLL Classes needs to be imported during your program's build.

You have to proceed this way :

In my Lib project:

In my lib global header :

#ifdef CUTE_TOOLKIT_DLL // Replace by your own DEFINE
# define EXPORT Q_DECL_EXPORT
#else
# define EXPORT Q_DECL_IMPORT
#endif

(you could use __declspec(dllimport), __declspec(dllexport))

In my lib widget classes :

class EXPORT qkBox : public QWidget
{
Q_OBJECT
//...

In my lib pro file :

DEFINES += CUTE_TOOLKIT_DLL