PDA

View Full Version : Quick question about adding mingw as compiler



melzk
23rd October 2012, 23:43
Hey

When i downloaded the qt sdk it installed the msvc2010 compiler and debugger,
And i want to have the mingw as compiler instead.

I have read that i can download the mingw to qt but in the package manager it shows that mingw alredy is installed. I have a compiler with mingw to but not for desktop. It is for the simulator option.

So my question is: how can i add mingw to the desktop compiler & build option?

ChrisW67
24th October 2012, 06:57
When i downloaded the qt sdk it installed the msvc2010 compiler and debugger,
No it didn't. It may have installed Qt libraries built using that compiler but Microsoft would take dim view of third parties distributing their compiler.

And i want to have the mingw as compiler instead.
The SDK installer does/can install this tool chain for the Windows target. If it has not then you can use the SDK maintenance tool to do it. You should to install a set of Qt libraries built with MingW at the same time if they were not installed by default.

I have read that i can download the mingw to qt but in the package manager it shows that mingw alredy is installed.
Hmmm, so what is the problem again? Open the Start Menu, find Qt SDK (or something like that) and start the command prompt. Type gcc -v to verify.

melzk
24th October 2012, 12:36
now i feel me dump, but i have to say i was to tierd last night now today i saw the mingw option in the updater i dident saw it yester day ;)

Added after 1 51 minutes:

now all is working, but i still have one problem. and i dont really know what that is for kind of problem.

Now when i can use the open cv headers and libaries, I tried to test a hello world app,
and when i paste the code i dont get anything, it just says like this.

Starting C:\c++\Opencv_test_mingw\release\Opencv_test_mingw .exe...
The program has unexpectedly finished.
C:\c++\Opencv_test_mingw\release\Opencv_test_mingw .exe exited with code -1073741511

here is the compiler output:


13:30:00: Running build steps for project Opencv_test_mingw...
13:30:00: Configuration unchanged, skipping qmake step.
13:30:00: Starting: "C:\QtSDK\mingw\bin\mingw32-make.exe"
C:/QtSDK/mingw/bin/mingw32-make.exe -f Makefile.Release
mingw32-make.exe[1]: Entering directory `C:/c++/Opencv_test_mingw'
mingw32-make.exe[1]: Nothing to be done for `first'.
mingw32-make.exe[1]: Leaving directory `C:/c++/Opencv_test_mingw'
13:30:00: The process "C:\QtSDK\mingw\bin\mingw32-make.exe" exited normally.

my .pro file:


#-------------------------------------------------
#
# Project created by QtCreator 2012-10-24T13:25:06
#
#-------------------------------------------------

QT += core gui

TARGET = Opencv_test_mingw
TEMPLATE = app


SOURCES += main.cpp\



INCLUDEPATH += "C:/OpenCV2.4MinGw/install/include"
LIBS += "C:/OpenCV2.4MinGw/bin/*.dll"

HEADERS +=

FORMS += mainwindow.ui


My main file:


#include <opencv/cv.h>
#include <opencv/highgui.h>

int main ( int argc, char **argv )
{
cvNamedWindow( "My Window", 1 );
IplImage *img = cvCreateImage( cvSize( 640, 480 ), IPL_DEPTH_8U, 1 );
CvFont font;
double hScale = 1.0;
double vScale = 1.0;
int lineWidth = 1;
cvInitFont( &font, CV_FONT_HERSHEY_SIMPLEX | CV_FONT_ITALIC,
hScale, vScale, 0, lineWidth );
cvPutText( img, "Hello World!", cvPoint( 200, 400 ), &font,
cvScalar( 255, 255, 0 ) );
cvShowImage( "My Window", img );
cvWaitKey();
return 0;
}


it sould make a window, but it isent doing that, what is the error?
when i debug and build i got this message (look on attachmented image)

have tryed a few other apps from the "http://qt-apps.org/"
with the same error.

ChrisW67
24th October 2012, 22:44
exited with code -1073741511
This 32-bit number is 0xC0000139 in hex. It means "DLL entry point not found" or something similar although finding that in Microsoft docs is not something I have done. Generally it means you are missing or have the wrong version of a DLL.

Load your program exe in Dependency Walker to see what it thinks in missing.

When you run your compiled program Windows needs to be able to find the libraries it depends on. Qt Creator ensure this for the Qt libraries, but external libraries you need to cater for yourself. The OpenCV libraries are probably not available in the run time environment. Either add the OpenCV bin directory (contains the OpenCV DLL files) to the system PATH or use Qt Creator's run configuration to set the extra PATH element only for Creator-launched programs.

melzk
25th October 2012, 18:47
hello again chris

i was so angry about this so, i reformatted my computer, so now i have a nice and clean verson of windows, qt sdk, mingw, cmake and the OpenCV libs
When i tried to rebuild it so i get the same damn error.

i used the Dependency walker and get this result:


Error: At least one required implicit or forwarded dependency was not found.
Warning: At least one delay-load dependency module was not found.
Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.

The dll's that is missing is:

QTCORE4.dll
QTGUI4.dll
QTTest4.dll
GPSVC.dll
IESHIMS.dll

I have also added the open cv lib / dll's to the system path variable. here is my path:

C:\Program Files (x86)\AMD APP\bin\x86_64;C:\Program Files (x86)\AMD APP\bin\x86;%SystemRoot%\system32;%SystemRoot%;%Sy stemRoot%\System32\Wbem;%SYSTEMROOT%\System32\Wind owsPowerShell\v1.0\;C:\Program Files (x86)\CMake 2.8\bin;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\MinGW\bin;C:\OpenCVB\bin;C:\OpenCVB\lib;

so what do you tink i should do next? i am so confused so i dont know what i should do? i also did a restart of evry time i changed the system variable.

EDIT +6 h:

Now som god news, I got the program to start. so what i have done:

copied all off the "qt sdk/desktop/x.x.x/mingw/bin" dll's to the appfolder. than it worked to make a exutable file. so i added the path to the exutable folder in the system path.

the problem now is that the program "The program has unexpectedly finished.
C:\Programering\test\release\test.exe exited with code -1073741511" so it wont be closed in the task manager.
but it starts, so i will try to look where the debugger dll's are and try to add them in the path to

EDIT: +6 h 10 min

i found them and they are in the same folder as the exutable dll's so why isent it working the. the files are in the system path variable.
i think i am totaly lost on this now.

ChrisW67
26th October 2012, 07:47
i was so angry about this so, i reformatted my computer, so now i have a nice and clean verson of windows, qt sdk, mingw, cmake and the OpenCV libs
When i tried to rebuild it so i get the same damn error.
I find it more productive to work the actual problem rather than just try stuff and hope it works. Getting angry... take a walk, clear your head, come back refreshed.

http://www.qtcentre.org/threads/46927-Location-of-imageformats-directory?p=211945#post211945
http://www.qtcentre.org/threads/51361-Program-runs-from-Creator-but-not-as-a-standalone?p=230734#post230734
To which I would add, your OpenCV libraries must also be reachable at run time by the program.

The crash you are experiencing is of the same type. Dependency Walker will show library dependencies that are required to start the program when you load it. The program can dynamically load libraries after that and DW can only see these if you use the profiling feature and run your program under DW control.

Are you still running just the test application from post #3?

BTW: What is the point of QTestLib in a release application?

melzk
26th October 2012, 09:02
I am trying to take it easy and think clear.
I tought i was near to fix it yesterday. But becase i read and test all kind of
Things and it not working. I have to try all kinde of other things.


The strange thing about this is that, if i make a new project without opencv
There are no errors. But when i runned the dependency walker it shows that
It is the standart qt fils that is missing.

The opencv files are working and can be found. So it is like qt just dont care about the orginal libs both for debugging and building the app.

Today i will test open cv with a standard c++ ide, so i se that it isent the opencv that is tricking me.
If it works. It must be some kinde of bug or something in the qt software.

ChrisW67
26th October 2012, 22:18
When you run your built program from inside an IDE the IDE typically ensures that the standard Qt libraries are in the PATH (LD_LIBRARY_PATH on Linux) the running program sees. When you load the program into DW the program is given the PATH that DW sees, usually the default Windows PATH, which does not include the Qt libraries... hence they are not found.

Are you trying to get the program to run in Qt Creator or standalone? First one first.

In Qt Creator:

Load your project
Select Projects from left toolbar.
Select Run from the options at the top of the page
Select your Run Configuration if you have more than one
Under Run Environment inspect the PATH variable.
You can adjust the environment to include the OpenCV bin directory and you should be done.