I found the reason but i have no idea why it cause the problem, Im using library that is linked to project but when i use its function, The instance returns null.
Qt Code:
LIBS += $$(STANDARD_XFS_DIRECTORY)/LIB/MSXFS.lib INCLUDEPATH += $$(STANDARD_XFS_DIRECTORY)/INCLUDETo copy to clipboard, switch view to plain text mode
Can anyone tell me why it happens?
mixed build mode perhaps? (release/debug)
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
No, Both are in debug!
The thing is, I did something exactly like this before with CMakeList.txt and Visual Studio but its not working with MinGW and QT Creator . I'm missing something but i have no idea what it is !!!
Added after 18 minutes:
The following configs of library and plugin in `CMakeList.txt` work perfectly fine when i make the project with `Visual Studio`. (Made with CMake)
Qt Code:
ADD_DEFINITIONS(${QT_DEFINITIONS}) ADD_DEFINITIONS(-DUNICODE -D_UNICODE) ADD_DEFINITIONS(-DQT_PLUGIN) ADD_DEFINITIONS(-DQT_SHARED) ADD_DEFINITIONS(-DQT_DLL) ADD_DEFINITIONS(-DQT_LARGEFILE_SUPPORT) ADD_DEFINITIONS(-DQT_THREAD_SUPPORT) INCLUDE_DIRECTORIES( ${STANDARD_XFS_DIRECTORY}/INCLUDE ) LINK_DIRECTORIES( ${STANDARD_XFS_DIRECTORY} ${STANDARD_XFS_DIRECTORY}/LIB ) SET(XFS_LIBS MSXFS xfs_conf SSIDLL ) TARGET_LINK_LIBRARIES(Device-Manager ${XFS_LIBS} )To copy to clipboard, switch view to plain text mode
And this is the configs of library and plugin in `.pro` file in `Qt Creator` with `MinGW` which is not working when i use the library.
Qt Code:
QT -= gui QT += core sql TARGET = Device-Manager TEMPLATE = lib CONFIG += plugin CONFIG += c++11 DEFINES += DEVICEMANAGER_LIBRARY INCLUDEPATH += $$(STANDARD_XFS_DIRECTORY) INCLUDEPATH += $$(STANDARD_XFS_DIRECTORY)/INCLUDE message(Include : $${INCLUDEPATH}) LIBS += $$(STANDARD_XFS_DIRECTORY)/SSIDLL.lib LIBS += $$(STANDARD_XFS_DIRECTORY)/LIB/MSXFS.lib LIBS += $$(STANDARD_XFS_DIRECTORY)/LIB/xfs_conf.lib message(Lib : $${LIBS})To copy to clipboard, switch view to plain text mode
So i can say the code it self is fine and i'm definitely missing some configs in `.pro` file.
PS1: Plugin and the application that load the plugin, Both have `INCLUDEPATH` and `LIBS` of the library in their pro file.
PS2: The application and the plugin both are in debug mode
PS3: I dont get any compile error or linker error during compile.
Last edited by meysam_hashemi; 12th December 2017 at 14:30.
do you have any other 3rd party dependencies which might be in release?No, Both are in debug!
I'd try to build your project in release and try to see if it works, its an easy test worth trying.
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
No man i dont
I made simple console application and included my library header and lib file and called the function and this is the error i get when i run the application. So it must be it. But seriously why!!!
The Code:
Qt Code:
LPWFSRESULT result = new WFSRESULT(); WFSFreeResult(result)To copy to clipboard, switch view to plain text mode
mingw.jpg
Is this typo 'DeviceMAnager' really in the code or only in the code posted here?:
Qt Code:
if (plugin) { deviceManager = qobject_cast<DeviceMAnager *>(plugin); return true; }To copy to clipboard, switch view to plain text mode
I'd add some defencive code here:
Qt Code:
if (plugin) { deviceManager = qobject_cast<DeviceMAnager *>(plugin); if(deviceManager) return true; return false;; } else { delete pluginLoader; return false; }To copy to clipboard, switch view to plain text mode
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
Your screenshot clearly shows error 0xc0000135, which means STATUS_DLL_NOT_FOUND. This goes back to:
Is the MSXFS.DLL in the run time PATH of the process or in the same directory as the plugin DLL? Is everything the MSXFS.DLL depends on also in one of those locations?Originally Posted by me
Yes.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Well, I found the problem however its so silly. I run project over windows 10 32 bit and it work fine. Maybe something is not incompatible with 64 bit and that caused this mess.
Thanks everyone for all your solution and i hope your solutions help others problem.
Thanks alot!
Bookmarks