[Solved] What's wrong with 8 bytes integers ? Exception at ... code: 0xc0000138
-
Hi.
I have Qt 5.1.0 for Windows 32-bit (MinGW 4.8, OpenGL)
on XP 32, sp3, Pentium Core2 duo.
After writing quite simple code in a test console application (to measure some expr. performance):
//////////////////
@#include "windows.h"
...
unsigned __int64 uiAverage = 0, uiCur; // was replaced with qulonglong
// with the same result...
LARGE_INTEGER li, li2;
QueryPerformanceCounter(&li);
expr;
QueryPerformanceCounter(&li2);
...
cout<<uiAverage;@
//////////////////////
I have encountered the following:
During first build, MinGw gives me nothing. But the prog shows "Press ENTER to close" instead of my output.
In debug it shows me a mesage box with: "Executable Failed with code 0xc0000138".
During next compilation I received from compiler this:
" error: An exception was triggered:
Exception at 0x7c966a3e, code: 0xc0000138: , flags=0x0."
After closing project and switchng off QtCreator, IDE was shure, that my project was still running... It gives me next message box with the text: "Force quit project ?"
///////////////////////////
I have repeated this action sequence several times, localized code lines, which triggered exception (with deletion of all generated files, and with new proj. too).
Sometimes compiler cursed even on <unsigned long long>, <qulonglong> declarations, not only at WinApi types, but without any WinApi at all;
(By the way, under VS2008 with cl.exe compiler, the code sample above is running perfectly.)
Any other Qt projects are working good;
//////////////////////////////////////////
QUESTION:
If it is a bug in QtCreator or MinGw compiler?
It is bad installation on XP? or I'm making something wrong?Thanks in advance
-
Hi,
Please put '@' before and after your code to make it readable.
-
@JKSH - Thanks for help with editor.
-
You're welcome.
What are you trying to achieve? Can you replace <windows.h> and Windows-specific functions with cross-platform Qt functions?
[quote]In debug it shows me a mesage box with: “Executable Failed with code 0xc0000138”.[/quote]Exception 0xc0000138 means your program can't find the correct entry point on the DLL it is trying to load.
Your program might be trying to load the wrong version of the DLL. To eliminate this risk, make sure that MinGW, Visual Studio, and Qt are not in your PATH.
[quote]Sometimes compiler cursed even on <unsigned long long>, <qulonglong> declarations[/quote]What do you mean?
-
[quote author="JKSH" date="1381997679"]
What are you trying to achieve? Can you replace <windows.h> and Windows-specific functions with cross-platform Qt functions?[/quote]- no. There are no cross platform analogs to QueryPerformanceCounter, which is under Win only. QElapsedTimer is close enough, but the doc for it saes: <The tick counter clock type is based on the system's or the processor's tick counter, multiplied by the duration of a tick. This clock type is used on Windows and Symbian platforms. If the high-precision performance counter is available on Windows, the PerformanceCounter clock type is used instead.> So if this functionality is platform dependent, why not use it directly? VS10-11 aren't support all c++11 features, but MinGw does. I want before using C++11 to check - if it good (fast at least) enough to use. And additionally I want to test - at what degree Qt supports direct WinApi calls.
[quote]To eliminate this risk, make sure that MinGW, Visual Studio, and Qt are not in your PATH.[/quote]
- not in the PATH.
[quote]Sometimes compiler cursed even on <unsigned long long>, <qulonglong> declarations. What do you mean?[/quote]
In a variables declarations I have replaced unsigned __int64 type with unsigned long long and qulonglong.
Thanks for PATH info.
Just now I tested it again... nothing was changed. This test sample works good:
@char sStr[200] = "Test";
GetCurrentDirectoryA(200, sStr);
cout<<sStr<<endl;@ -
[quote author="aiJudgementForAll" date="1381999711"]So if this functionality is platform dependent, why not use it directly?[/quote]There are 3 reasons people use the high-level API instead of implementing things directly:
- Cleaner code. QElapsedTimer already calls QueryPerformanceCounter internally and does the necessary checks (see https://qt.gitorious.org/qt/qtbase/source/src/corelib/tools/qelapsedtimer_win.cpp ). This saves time for developers.
- Portability. If you implement something directly and try to run it on a machine that doesn't support it, the program will fail. If you used Qt's high-level API, Qt will automatically select an appropriate backup implementation.
- Reduced external dependencies. This reduces the risk of DLL errors, like what you're experiencing.
Regarding your DLL error, your .pro file might contain a clue. Can you post your .pro file here?
[quote]And additionally I want to test - at what degree Qt supports direct WinApi calls. [/quote]Qt is just like any other C++ library. You can mix Qt, Boost, and the Windows API in one project if you want.
In fact, Qt calls Windows API directly on Windows (see the QElapsedTimer example above)
[quote][quote]To eliminate this risk, make sure that MinGW, Visual Studio, and Qt are not in your PATH.[/quote]
- not in the PATH.[/quote]How about your local environment? How did you compile your program? (Did you use Qt Creator, or the command line?)
[quote]In a variables declarations I have replaced unsigned __int64 type with unsigned long long and qulonglong.[/quote]I meant, what did you mean when you said "the compiler cursed"? Was it a compile-time error, link-time error or run-time error?
-
@JKSH - Thanks for your help and time!
[quote] How did you compile your program?[/quote]- I use QtCreator.
[quote] Qt is just like any other C++ library. You can mix Qt, Boost, and the Windows API in one project if you want.[/quote]
It is exactly what I unsuccessfully trying to do - test it;[quote]what did you mean when you said "the compiler cursed"? Was it a compile-time error, link-time error or run-time error?[/quote]
- There was both types of errors. Compile time error and runtime.
After writing LARGE_INTEGER li, li2; line and compiling (first time),
compiler sometimes shows me exception at compile time.
<Exception at 0×7c966a3e, code: 0xc0000138: , flags=0×0.>
Sometimes not. In runtime I see in this case <Press ENTER to exit> (it is a test console app). In debug it shows me a message box with: “Executable Failed with code 0xc0000138”.
Now I think about the following reason: I have old XP, with critical updates untill 2011. If Microsoft had changed it's dlls during these updates, entry points for functions, which are linked through *.lib-s are changed too. So, If Qt compiler expects updated dlls - my case is completely explained - it is my fault - I need new updated XP.
What is your opinion?
-
You're welcome :)
[quote]compiler sometimes shows me exception at compile time.
<Exception at 0×7c966a3e, code: 0xc0000138: , flags=0×0.>[/quote]That's worse than a compile-time error.When a compiler is working properly, it can give compile-time errors like "This syntax is wrong" or "This header file cannot be found". However, it should never throw exceptions.
Since you are getting exceptions, that means your compiler itself (or the components that it depends on) is broken. You will need to fix it before you can compile anything reliably.
[quote]Now I think about the following reason: I have old XP, with critical updates untill 2011.[/quote]That is quite old, but I don't know if Microsoft released any incompatible updates since 2011 then.
I do know that Windows XP will reach end-of-life in April 2014; I don't recommend starting any new projects in an XP environment. Also, you mentioned that you want C++11 with Visual Studio. The last version of Visual Studio supported on XP is Visual Studio 2010, which does not support C++11. You need Visual Studio 2012 with a newer version of Windows.
If you still want to continue trying MinGW:
- Do you have a newer PC that you can use for compilation?
- You can try running Dependency Walker on your compiler to see which DLLs it is trying to load -- it might give you some clues.