I need to compile some source code into a DLL, and load it in other project. I have an entry called
extern "C" LTCPOS_LSHARED_EXPORT tcpClient_Os* getClientInst(VhostInfo hostInfo, CtcpOpt *tcpOpt, QObject *parent = 0);
The type of "tcpClient_OS" is a self-defined class. When I load the DLL using QLibrary in a different project it appears that I must add the source file (cpp files) into the *.pro in order to make the project compiled without errors. Why?
What is the normal routine of building a DLL with a function returning self-defined class pointer and how do I load it?
Not to familiar with building qt stuff but in windows we normally need a lib and some header files to call something in another dll. We also have LoadLibrary, GetProcAddress for executing stuff that is not known at compile time.
It looks like it is very similar building qt stuff. Compile your dll, it addition to the dll itself it should produce a lib. In proj config for referencing project need a LIBS += with path to the lib.
Here is a link I found on QLibrary which is an abstraction for Windows LoadLibrary/GetProcAddress and dlopen/dlsym http://tufangorel.blogspot.com/2011/11/call-symbol-from-shared-object-file-dll-with-qlibrary.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.