2
votes

i want to get started with QT. I donwloaded QT5 MINGW compiler with QT creator and i am trying to build the pre attached example named affine the problem is that the QT5 i think embed the project name with each of source file and thus gives error that file not found. some thing similar

    :-1: error: ..affinemain.cpp: No such file or directory

while the file name is just

    main.cpp 

i don't know how to fix it. I searched lot on internet but could not found anything useful. I even try to compile from command prompt but i am not fimmiliar with command prompt compiling as i am new to QT and previously i am totally developed with IDE in visual studio and eclipse for java so i have no idea about the make file and compiler command line arguments. could some body please help me to fix this issue and can you tell please why compiler attaching project name with the source file name? Thanks in advance

2

2 Answers

2
votes

I have got the same problem and my solution may help you.

I am working with Qt5.0.1 now, and there are two distributions to work on windows with it: Qt5.0.1-mingw and Qt5.0.1-msvc2010. I had to use mingw and there was a problem on my setup that "/" is ignored in path's.

So according to Qt Creator, compiler was called to process file mainwindow.cpp and this file was passed to it

g++ /*truncated*/ ..\qt-example\mainwindow.cpp

Below is the full compiler input:

g++ -c -pipe -fno-keep-inline-dllexport -g -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_OPENGL_ES_2 -DQT_OPENGL_ES_2_ANGLE -DQT_NEEDS_QMAIN -I..\qt-example -I"..\..\..\..\..\..\Qt\Qt5.0.1\5.0.1\mingw47_32\include" -I"..\..\..\..\..\..\Qt\Qt5.0.1\5.0.1\mingw47_32\include\QtWidgets" -I"..\..\..\..\..\..\Qt\Qt5.0.1\5.0.1\mingw47_32\include\QtGui" -I"..\..\..\..\..\..\Qt\Qt5.0.1\5.0.1\mingw47_32\include\QtCore" -I"debug" -I"." -I"." -I"..\..\..\..\..\..\Qt\Qt5.0.1\5.0.1\mingw47_32\mkspecs\win32-g++" -o debug\mainwindow.o ..\qt-example\mainwindow.cpp

And the error produced.

g++.exe: error: ..qt-examplemainwindow.cpp: No such file or directory
g++.exe: fatal error: no input files
compilation terminated.

So, we can see that "\" is ignored by the compiler and file name is merged with directory name.

The solution to that problem goes to the tools that are used - MinGW (Minimalist ports of GCC and Binutils). And also MSYS - a collection of GNU utilities such as bash, make, gawk and grep to allow building of applications and programs which depend on traditionally UNIX tools to be present. In our case - g++.

MSYS is not shipped with Qt5.0.1-mingw and g++ is not using it, but having MSYS available in your PATH environment variable breaks the system.

MSYS is used for git scm, which I have installed, so my path contains links to MSYS that goes bundled with git. So I have next paths in my PATH environment variable.

C:\Program Files (x86)\git\bin;C:\Program Files (x86)\git\cmd

I have not found how MSYS is used by Qt Creator or g++, or where it is linked, but when I have dropped next path from PATH:

C:\Program Files (x86)\git\bin;

and restarted Qt Creator - g++ succeeded on compiling my file, it worked. The question why/how it influences the Qt Creator/g++ that should not use MSYS utils installed with git is still open.

0
votes

i can“t comment.

important : delete all the files in the release and debug folder (compiled version) before try the tips of the autor ...