Reputation: 11
I'm trying to run a simple example program Qt dialog example. I compiled it using cmake and nmake, but upon running I get:
Cannot correctly start the application (0xc0150002). Click OK to close the application.
The main.cpp I'm using:
#include <QApplication> #include "dialog.h" int main(int argc, char *argv[]) { QApplication app(argc, argv); Dialog dialog; return dialog.exec(); }
The simplest thing I can get to work is
#include <QApplication> #include <iostream> #include "dialog.h" using namespace std; int main(int argc, char *argv[]) { cout << "test!" << endl; // QApplication app(argc, argv); // Dialog dialog; //return dialog.exec(); return 0; }
So I can't use anything Qt related, any ideas on how to solve this issue?
Thanks!
Upvotes: 0
Views: 1144
Reputation: 1
I used the tool and found that a few dll's seem to be missing. These being MSVCP90D.DLL, MSVCR90D.DLL, GPSVC.DLL, IESHIMS.DLL.
After some googling it seemed that the problem could be using VS2010 with precompiled Qt binaries for VS 2008. Now I recompiled Qt with VS 2010 but the problem remains the same.
But when recompiling I also compiled the examples, including the one I was trying to get to run. Seems the compiled example of Qt runs perfectly, but my own compiled version keeps giving the same error and the dll's are still missing..
How is this possible, I'm compiling with the same Qt include/binary dir?
The information asked: the CMakeLists.txt:
cmake_minimum_required (VERSION 2.6) PROJECT(test)
FIND_PACKAGE(Qt4) INCLUDE(${QT_USE_FILE}) ADD_DEFINITIONS(${QT_DEFINITIONS})
LINK_LIBRARIES( ${QT_LIBRARIES} )
set(all_SOURCES main.cpp) QT4_AUTOMOC(${all_SOURCES}) add_executable(Test ${all_SOURCES}) target_link_libraries(Test ${LINK_LIBRARIES})
I'm using Visual Studio 2010 on Windows 7. I'm using the VS2010 command prompt to build and run the executable.
Thanks!
Upvotes: 0
Reputation: 2643
It might be that your Qt dlls aren't found when the program starts.
You can check this by copying Qt dll files from Qt's Bin folder to the folder where your program executable is.
Or set the PATH system variable to contain the folder where the Qt libraries are, dlls under windows.
If you are under windows, then there is a tool you can use.
Depedency Walker, to start it, start the "visual studio command prompt" and type "depends"
Drag & Drop your application file to the dependency walker and you should see what dlls it cannot load.
Note that the program isn't always accurate though, but in your case it should work.
Upvotes: 2