VB vs Qt dll combination
-
I get the following error message "Entry Point Not Found" when trying to use a Qt compiled dll from a Visual Studio compiled dll. Please note that the error refers to a symbol in the VS compiled dll.
What may be going wrong? How can I spot the error?
These are the details:
I had the following architecture: a.exe uses a.dll , a.dll uses b.dll .
The three files were probably compiled with Visual Studio (possibly VS2012). The program worked fine. I have the Visual Studio projects for a.dll and b.dll (but a.dll is not recompilable because I lack required frameworks).Now, I have compiled a modified version of b.dll in Qt but when I attempt to use it I get the aforementioned error message (please note that the error message is about an entry point not found in a.dll, not in my Qt compiled b.dll).
-
Hi, just a guess but it could be some mixup of architectures, like 64-bit instead of 32-bit, ANSI instead of Unicode, Multithreaded instead of SingleThreaded runtime or different calling conventions (fastcall vs. stdcall etc.).
You can use the dumpbin utility in Visual Studio to see what symbols are exported and imported for the different dlls. Print them out and have a cup of coffee :-)
-
Or, if you'd like less cryptic output, you can use "DependencyWalker":http://www.dependencywalker.com/
What exactly do you mean by "compiled with Qt", as Qt is just a library. Do you mean you used Qt Creator(the IDE)? What compiler did you use? If you used MinGW then it won't be compatible with the VS dlls.
-
Thanks for the answers.
[quote author="hskoglund" date="1400280277"]Hi, just a guess but it could be some mixup of architectures, like 64-bit instead of 32-bit, ANSI instead of Unicode, Multithreaded instead of SingleThreaded runtime or different calling conventions (fastcall vs. stdcall etc.).
You can use the dumpbin utility in Visual Studio to see what symbols are exported and imported for the different dlls. Print them out and have a cup of coffee :-)
[/quote]dumpbin confirmed the same architecture for both DLLs (at least in FILE HEADER VALUES).
[quote author="Chris Kawa" date="1400314196"]Or, if you'd like less cryptic output, you can use "DependencyWalker":http://www.dependencywalker.com/
What exactly do you mean by "compiled with Qt", as Qt is just a library. Do you mean you used Qt Creator(the IDE)? What compiler did you use? If you used MinGW then it won't be compatible with the VS dlls.[/quote]
Yes, I have used Qt Creator with mingw. May I change the compiler settings in QTCreator in order to use VisualStudios's C compiler? I'm using Qt Creator 3.0.82 and VS Express 2012.
-
Yeah it's like Chris Kawa says, an app/single .exe file cannot have both MinGW-flavored DLLs and Visual Studio DLLs :-(
So you need to setup or reinstall QtCreator for Visual Studio.(In your program, you can freely mix DLLs from Visual Studio Professional or Express 2010, 2012 or 2013, it's just MinGW that's not kosher.)
-
You don't need to re-install Qt Creator. The VS compiler should be already automatically detected. All you have to do is download and install VS compiled Qt and "setup a kit":http://qt-project.org/doc/qtcreator-3.1/creator-targets.html
If you used the online installer it's as easy as running the maintenance tool and selecting a Qt version. The kit will be set up for you.It's also not true(well not entirely at least) that you can mix dlls between VS versions. It greatly depends on the features you export and consume in the dll.
For example the stl containers changed their size and layout between versions so passing a VS2010 vector to a VS2012 dll function will most probably crash your program or cause undebuggable bugs.The only safe way to mix dlls between versions is to stick to pure "C" interface i.e. not exporting classes, functions operating on simple types (eg. no stl containers or std::string as params) and manually control structs alignment (the defaults sometimes change too).
It's also important (as hskoglund mentioned) to keep an eye on the various compiler and runtime settings. They need to match.All in all it's a lot easier to just stick to one compiler and same settings for all components in your project.
-
Aha thanks Chris, didn't know about sizeof stl containers changed, I thought because I could use VS2012/2013 for plugins for QtCreator (which is built with VS2010) then it was a free mixing game.
(Off topic: MS has a long slightly unhappy story with STL support, I remember VS6, if you tried to use a vector (defined in your main program) from a DLL it crashed) -
Yeah, VS6 was a nightmare of a release. The stl and template horrors haunt many souls to this very day :)
But nah, we're 7 releases later now and these dark days are mostly over. They're actually doing quite ok job now. I mean they are way behind with the C++11/14 and have some bugs but who doesn't? For example I recently discovered a curious Clang bug that wouldn't generate destructor invocations in some cases. That was (not so)fun debugging exercise ;) Oh well, that's the life of a developer I guess.As for the container sizes "here's a nice summary table at the bottom for VS2012/VC 11.0":http://blogs.msdn.com/b/vcblog/archive/2011/09/12/10209291.aspx, but it's just one of the things that changed. There are quite some more.