Qt creator use .so in linux
-
Qt Creator usually uses qmake to build its stuff, so I have to refer you to "the qmake documentation":http://doc.qt.nokia.com/latest/qmake-variable-reference.html#libs.
-
Section "Declaring Other Libraries" of the "qmake Project Files":http://developer.qt.nokia.com/doc/qt-4.7/qmake-project-files.html manual has an example on how to use external libraries in your project.
-
When I try to open a shared library **.so,Qt Creator shows this mistake:
Fatal error: cannot get path to runtime module.[quote author="Volker" date="1323778201"]Section "Declaring Other Libraries" of the "qmake Project Files":http://developer.qt.nokia.com/doc/qt-4.7/qmake-project-files.html manual has an example on how to use external libraries in your project.[/quote]
-
@
void *handle;
void (*myfun)(void);
char *error;handle = dlopen ("libadd.so", RTLD_LAZY);
if (!handle) {
fprintf (stderr, "%s\n", dlerror());
}dlerror();
*(void **) (&myfun) = dlsym(handle, "add");dlerror();
(*myfun)();
dlclose(handle);@
[EDIT: code formatting, Volker]
-
Ah, you try to open it in your own application and you see a runtime error message in Creator's output tabs, now I understand.
Hm, seems as if dlopen doesn't know where to search for your .so - you'll have to use your OS' methods for search paths or use an absolute path.
Did you consider using [[Doc:QLibrary]] to replace dlopen?
-
@
typedef int (*MyPrototype)(int,int);
MyPrototype myFunction =
(MyPrototype) QLibrary::resolve("/home/liu111/123/libadd.so", "add");
int aa=myFunction(0,1);
@these codes stops:int aa=myFunction(0,1)
and Ccreator says :"The program has unexpectedly finished."
But it works very well for the .so provided by MATLAB,like libm.so,and I have tested "cos" from libm.so ,and it works very well. The libadd.so is generated by the libadd.m which is written by myself.The method generating .so from .m works perfectly usder win32,maybe the above problem is caused by MATLAB does not coordinate with linux perfectly. -
My library is made of Matlba-code . Matlab can generate *.so from *.m .
Thank you very much.