PDA

View Full Version : Load objects from dynamic library



Trok
18th June 2009, 12:21
Hi, I want load objects with dynamic library without result ;/
I add in *.pro file:

LIBS += -Lpath -lname
and in *.cpp or *.h

extern "C" class __declspec(dllimport) testclass{};

It doesn't work. Why? Does it good prepare?

shentian
18th June 2009, 12:40
I'm not sure about the 'extern "C"'. And I'd use macros as explained here (http://doc.trolltech.com/4.5/sharedlibrary.html).

Anyway, what does not work? Do you get a linker error or a runtime error?

Trok
18th June 2009, 12:50
My program not complie ;/ I haven't any reports from debugger.
How can I use Q_DECL_IMPORT in my file who import library?
Btw:
LIBS += -LC:\Documents and Settings\bla\Pulpit\Qt Progs\LoaderObj\debug -lLoaderObj is it correctly? It isn't building me now.

spirit
18th June 2009, 13:23
do you write this library by yourself? if yes read this (http://www.qtcentre.org/forum/p-dll-using-qt-post86389/postcount2.html) and modify it.
maybe QLibrary also can help you.

Trok
18th June 2009, 23:44
Hi, I use QLibrary, and have some problem with action.
It's my code:
1.In *.dll

void LOADEROBJSHARED_EXPORT kamil()
{}
2. In app


typedef void (*AvgFunction)();
QMessageBox kamil;
QLibrary library("LoaderObj.dll");
library.load();
AvgFunction avg = (AvgFunction) library.resolve("kamil");
if (avg)
kamil.setText("good");
else
kamil.setText("bad");

kamil.exec();

Why it don't laod my function while load library? ;/

sumitgogna
17th July 2009, 13:07
I am having similar problems. I am new to libs and Qt. Anyone plz solve this problem.

yogeshgokul
17th July 2009, 13:13
Why it don't laod my function while load library? ;/
You have to load first the library and then methods.

kuzulis
17th July 2009, 14:58
For load classes from dynamic library see this link
http://www.prog.org.ru/topic_8259_0.html

PS: Russian language :)

yogeshgokul
17th July 2009, 15:02
PS: Russian language :)
Impossible for most of us. :)
But QLibrary::resolve() can resolve all exported symbols. Just remember you have to add this prefix @ the time of exporting symbols from dll.
__declspec(dllexport) ///FOR WINDOWS ONLY

kuzulis
17th July 2009, 19:29
Impossible for most of us.


Use http://translate.google and you will be a great happiness :)

wysota
17th July 2009, 21:04
I am having similar problems. I am new to libs and Qt. Anyone plz solve this problem.

Could you explain the problem? What errors do you get?