1 Attachment(s)
compilation errors "gcc: all: No such file or directory"
Code:
#include <QApplication>
#include <QDebug>
int main(int argc,char*argv[]){
qDebug()<<"Helloworld";
return 0;
}
sample_pr_commandline.pro file:
TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .
# Input
SOURCES += first.cpp
namus@namus-desktop:~/Sample_Qt_progs/sample_pr_commandline$ ls
first.cpp sample_pr_commandline.pro
namus@namus-desktop:~/Sample_Qt_progs/sample_pr_commandline$ qmake
namus@namus-desktop:~/Sample_Qt_progs/sample_pr_commandline$ ls
first.cpp Makefile sample_pr_commandline.pro
namus@namus-desktop:~/Sample_Qt_progs/sample_pr_commandline$ make
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -o first.o first.cpp
g++ -Wl,-O1 -o sample_pr_commandline first.o -L/usr/lib -lQtGui -lQtCore -lpthread
gcc first.o all -o first
gcc: all: No such file or directory
make: *** [first] Error 1
Makefile is attached to this thread.
I am not getting why this error is coming & other programs are running fine.
Re: compilation errors "gcc: all: No such file or directory"
It looks like it can't find first.o
Can you do an ls in the build directory after the compilation error?
Re: compilation errors "gcc: all: No such file or directory"
Make is confusing a target "first" generated by qmake in the Makefile with the file "first" and related targets. Rename your source file.
Re: compilation errors "gcc: all: No such file or directory"
Thanks Chris,
After renaming the first.cpp to myprog.cpp, works fine .
but i didnt clearly understood the reason , can u explain in detail !!!
Re: compilation errors "gcc: all: No such file or directory"
The Makefile contains a generated (fake) target called "first" and it also contains a set of explicit and implied rules related to the source file "first.cpp". The make command builds your TARGET (which is named after the directory if not specified) and then decides that because "first.o" changed it must rebuild the "first" target: at this point it gets confused.
Code:
$ make
/usr/bin/moc -DQT_NO_DEBUG -DQT_SQL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtSql -I/usr/include/qt4 -I. -I. first.cpp -o first.moc
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_SQL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtSql -I/usr/include/qt4 -I. -I. -o first.o first.cpp
g++ -Wl,-O1 -Wl,-rpath,/usr/lib/qt4 -o simple_example first.o -L/usr/lib/qt4 -lQtSql -L/usr/lib/mysql -L/usr/lib/qt4 -lQtGui -L/usr/X11R6/lib -lQtCore -lgthread-2.0 -lrt -lglib-2.0 -lpthread
gcc first.o all -o first // <<<<< confused, decides to rebuild "first" target using a file called "all"
gcc: all: No such file or directory
make: *** [first] Error 1
You get similar confusion (that make recovers from) if "TARGET = first" even with no files called "first.cpp".
Code:
$ make
/usr/bin/moc -DQT_NO_DEBUG -DQT_SQL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtSql -I/usr/include/qt4 -I. -I. main.cpp -o main.moc
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_SQL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtSql -I/usr/include/qt4 -I. -I. -o main.o main.cpp
make: Circular all <- first dependency dropped. // <<<< confused but recognises the situation
g++ -Wl,-O1 -Wl,-rpath,/usr/lib/qt4 -o first main.o -L/usr/lib/qt4 -lQtSql -L/usr/lib/mysql -L/usr/lib/qt4 -lQtGui -L/usr/X11R6/lib -lQtCore -lgthread-2.0 -lrt -lglib-2.0 -lpthread
Adding to Makefile fixes this problem but probably generates another if the TARGET = first. The change would be overwritten by qmake anyway. Easier to just avoid it.