PDA

View Full Version : 0xc0000005 when linking against lib



niko
6th March 2006, 20:59
I'm currently doing a exercise of the OopDocbook:
http://cartan.cas.suffolk.edu/moin/OopDocbook?page=x-dataobjects.html
(free registration required to view this)

I created a very simple PetManager (as described in the example) - and link this to libdataobjects. (download here: http://cartan.cas.suffolk.edu/oopdocbook/dist/)

From my pro-file:
INCLUDEPATH += d:\qt\libs\dataobjects
win32:LIBS += d:\qt\libs\libdataobjects.a
(i complied libdataobjects.a myselfe)

....when i now use the DataObject-Class from libdataobjects compiling and linking works fine, but the compiled application exits with: "Can't initialize the Application (0xc0000005)."

I found out that this stands for Permission denied. But what does that mean?



When I don't use Q_OBJECT in the class that inherits DataObject everything works fine (but i can't use signal/slots etc then ofcourse)



please help!

(PS: I'm on Win2k, Qt4.1, MinGW)

jacek
6th March 2006, 21:47
When I don't use Q_OBJECT in the class that inherits DataObject everything works fine (but i can't use signal/slots etc then ofcourse)
Did you run qmake to get a new Makefile after adding Q_OBJECT?

niko
7th March 2006, 06:06
thanks for the reply,

Did you run qmake to get a new Makefile after adding Q_OBJECT?
yes i did.

niko
7th March 2006, 06:58
Some more information I found out:
- When i start the debugger and make exactly one step-into the application quits with the same error-message.

- when i don't link to libdataobjects but instead copy the source-files of the used classes to my application everything works fine
(so i assume it's a problem with the linking...)

jacek
7th March 2006, 16:58
Did you compile that library in release or debug mode? Do you use the same mode for your application?

niko
7th March 2006, 19:32
i did build both in debug mode.

and tried both in release-mode too - doesn't help.

niko
7th March 2006, 20:06
I attached my files, perhaps someone would like to help and see if he can reproduce the problem
(or - better - tell me what i'm making wrong)

steps to reproduce:

unpack attached zip
set CPPLIBS=absolutepath to libs-dir (used by qmake-scripts)
cd libs
qmake
make
cd ..
cd PetManager
qmake
make
debug\PetManager

jacek
7th March 2006, 20:24
I attached my files, perhaps someone would like to help and see if he can reproduce the problem
I think it works:
ohje
"
<object class="PetList" name="" >

<object class="Pet" name="" >
<property name="Type" type="QString" value="Kuh" />
<property name="Breed" type="QString" value="Schwarzbunt" />
<property name="Name" type="QString" value="Serena" />
<property name="ID" type="int" value="20" />
<property name="Birthday" type="QDate" value="2001-02-12" />

<object class="Maintenance" name="" >
<property name="Event" type="QString" value="Klauen schneiden" />
<property name="Date" type="QDate" value="2006-01-12" />
<property name="Cost" type="int" value="100" />
</object>

</object>

</object>
"
Hallo(I use PLD Linux and Qt 4.1.1).

Did you buld those libraries as static ones or as DLLs? Did you try to copy all DLLs to the directory where your executable is?

niko
7th March 2006, 21:39
much thanks for testing!
(how bad it works for you... probably only a problem on win32?)

[qoute]Did you buld those libraries as static ones or as DLLs? Did you try to copy all DLLs to the directory where your executable is?[/quote]
as dll (the standard-behaviour)

...and yes - i copied the dlls into the direcotory.

jacek
7th March 2006, 21:57
probably only a problem on win32?
Yes, I just checked the sources and all classes are declared like this:

class DataObject : public QObject {
Q_OBJECT
// ...
};
Which means that they aren't ready for use in DLLs (in short: you can't use those classes outside the DLL, because they're not exported).

It should be:
class EXPORT DataObject : public QObject {
Q_OBJECT
// ...
};Where EXPORT macro is either __declspec(dllimport), __declspec(dllexport) or empty. See this thread (http://www.qtcentre.org/forum/showthread.php?t=638) for more info.

niko
8th March 2006, 08:55
aaah, much thanks for that hint!

i compiled the libary now static and everything is working just fine!

big thanks!