PDA

View Full Version : compilation errors "gcc: all: No such file or directory"



namus
22nd July 2010, 06:35
#include <QApplication>
#include <QDebug>

int main(int argc,char*argv[]){

QApplication a(argc,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.

tbscope
22nd July 2010, 07:11
It looks like it can't find first.o

Can you do an ls in the build directory after the compilation error?

ChrisW67
23rd July 2010, 00:03
Make is confusing a target "first" generated by qmake in the Makefile with the file "first" and related targets. Rename your source file.

namus
26th July 2010, 06:18
Thanks Chris,
After renaming the first.cpp to myprog.cpp, works fine .
but i didnt clearly understood the reason , can u explain in detail !!!

ChrisW67
26th July 2010, 07:02
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.


$ 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".


$ 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
.PHONY = first 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.