PDA

View Full Version : Added new class to clean Qt application, gotcompile error "No such file or directory"



sundbergad
5th March 2015, 10:20
Hi,

I'm fairly new to Qt.

In a larger GUI programming project, on Linux with Qt Creator 5.2. Now I need to split things up and therefor make som tests

I'm about to make a namespace test and in order for that, I create a new QApplication, compile out of the box - OK
Next I add a new C++ class that inherit from QObject.
Straight out of the box, it compiles

Now when I add the class it fails to compile straight of with two errors
Error: all: "No such file or directory"
[first] Error 1

Guess it has to do with paths missing but where??
Suggestions??




#include <QMainWindow>

namespace Ui { class MainWindow; }

class MainWindow : public QMainWindow
{
Q_OBJECT

public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();

....


#include <QObject>

class First : public QObject
{
Q_OBJECT
public:
explicit First(QObject *parent = 0);

signals:
...

// in .cpp
#include "first.h"

First::First(QObject *parent) :
QObject(parent)
{
}

anda_skoa
5th March 2015, 11:14
Which file does it not find?

Cheers,
_

sundbergad
5th March 2015, 12:41
Hi anda_skoa

Good question, this is all info the compiler sends out, 2 lines of error!!????

anda_skoa
5th March 2015, 14:10
that's very unlikely.

Make sure you are looking at the compile output tab

Cheersm
_

sundbergad
5th March 2015, 14:31
Hi, yes I'm sure, attached a screenshot, as it looks (didn't display the code though
10997

Lesiok
5th March 2015, 14:40
This is not "compile output". Look at another tab where You see clean aoutput from compiler.

sundbergad
5th March 2015, 14:57
OK, another image then
10998

Lesiok
5th March 2015, 15:09
gcc is looking for file all.

sundbergad
5th March 2015, 15:18
OK, so how does that happen??
Shall I edit the makefile or what??

wysota
5th March 2015, 16:54
What does the project file look like?

sundbergad
6th March 2015, 07:04
Hi, Godmorning

the .pro file looks like this


-------------------------------------------------
#
# Project created by QtCreator 2015-03-03T02:16:46
#
#-------------------------------------------------

QT += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = t2
TEMPLATE = app


SOURCES += main.cpp\
mainwindow.cpp \
first.cpp

HEADERS += mainwindow.h \
first.h

FORMS += mainwindow.ui



Added after 35 minutes:

Leisok, I found this in the autogenerated makefile, Do you think it has something to do with it??


QMAKE_TARGET = t2
DESTDIR = #avoid trailing-slash linebreak
TARGET = t2


first: all
####### Implicit rules

.SUFFIXES: .o .c .cpp .cc .cxx .C

.cpp.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"

.cc.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"

.cxx.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"

.C.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"

.c.o:
$(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"

####### Build rules

all: Makefile $(TARGET)

wysota
6th March 2015, 07:46
Delete the Makefile and rebuild the project.

sundbergad
6th March 2015, 10:09
Deleted and rebuild, same problem. This is the compiler output


19:54:21: Running steps for project t2...
19:54:21: Starting: "/home/anders/Qt/5.2.0/gcc/bin/qmake" /home/anders/programmering/t2/t2.pro -r -spec linux-g++ CONFIG+=debug CONFIG+=declarative_debug CONFIG+=qml_debug
19:54:21: The process "/home/anders/Qt/5.2.0/gcc/bin/qmake" exited normally.
19:54:21: Starting: "/usr/bin/make"
g++ -c -pipe -g -Wall -W -D_REENTRANT -fPIE -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../Qt/5.2.0/gcc/mkspecs/linux-g++ -I../t2 -I../../Qt/5.2.0/gcc/include -I../../Qt/5.2.0/gcc/include/QtWidgets -I../../Qt/5.2.0/gcc/include/QtGui -I../../Qt/5.2.0/gcc/include/QtCore -I. -I. -I. -o first.o ../t2/first.cpp
/home/anders/Qt/5.2.0/gcc/bin/uic ../t2/mainwindow.ui -o ui_mainwindow.h
g++ -c -pipe -g -Wall -W -D_REENTRANT -fPIE -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../Qt/5.2.0/gcc/mkspecs/linux-g++ -I../t2 -I../../Qt/5.2.0/gcc/include -I../../Qt/5.2.0/gcc/include/QtWidgets -I../../Qt/5.2.0/gcc/include/QtGui -I../../Qt/5.2.0/gcc/include/QtCore -I. -I. -I. -o main.o ../t2/main.cpp
g++ -c -pipe -g -Wall -W -D_REENTRANT -fPIE -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../Qt/5.2.0/gcc/mkspecs/linux-g++ -I../t2 -I../../Qt/5.2.0/gcc/include -I../../Qt/5.2.0/gcc/include/QtWidgets -I../../Qt/5.2.0/gcc/include/QtGui -I../../Qt/5.2.0/gcc/include/QtCore -I. -I. -I. -o mainwindow.o ../t2/mainwindow.cpp
/home/anders/Qt/5.2.0/gcc/bin/moc -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../Qt/5.2.0/gcc/mkspecs/linux-g++ -I../t2 -I../../Qt/5.2.0/gcc/include -I../../Qt/5.2.0/gcc/include/QtWidgets -I../../Qt/5.2.0/gcc/include/QtGui -I../../Qt/5.2.0/gcc/include/QtCore -I. -I. -I. ../t2/mainwindow.h -o moc_mainwindow.cpp
g++ -c -pipe -g -Wall -W -D_REENTRANT -fPIE -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../Qt/5.2.0/gcc/mkspecs/linux-g++ -I../t2 -I../../Qt/5.2.0/gcc/include -I../../Qt/5.2.0/gcc/include/QtWidgets -I../../Qt/5.2.0/gcc/include/QtGui -I../../Qt/5.2.0/gcc/include/QtCore -I. -I. -I. -o moc_mainwindow.o moc_mainwindow.cpp
/home/anders/Qt/5.2.0/gcc/bin/moc -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../Qt/5.2.0/gcc/mkspecs/linux-g++ -I../t2 -I../../Qt/5.2.0/gcc/include -I../../Qt/5.2.0/gcc/include/QtWidgets -I../../Qt/5.2.0/gcc/include/QtGui -I../../Qt/5.2.0/gcc/include/QtCore -I. -I. -I. ../t2/first.h -o moc_first.cpp
g++ -c -pipe -g -Wall -W -D_REENTRANT -fPIE -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../Qt/5.2.0/gcc/mkspecs/linux-g++ -I../t2 -I../../Qt/5.2.0/gcc/include -I../../Qt/5.2.0/gcc/include/QtWidgets -I../../Qt/5.2.0/gcc/include/QtGui -I../../Qt/5.2.0/gcc/include/QtCore -I. -I. -I. -o moc_first.o moc_first.cpp
g++ -Wl,-rpath,/home/anders/Qt/5.2.0/gcc -Wl,-rpath,/home/anders/Qt/5.2.0/gcc/lib -o t2 main.o mainwindow.o first.o moc_mainwindow.o moc_first.o -L/home/anders/Qt/5.2.0/gcc/lib -lQt5Widgets -lQt5Gui -lQt5Core -lGL -lpthread
{ test -n "" && DESTDIR="" || DESTDIR=.; } && test $(gdb --version | sed -e 's,[^0-9][^0-9]*\([0-9]\)\.\([0-9]\).*,\1\2,;q') -gt 72 && gdb --nx --batch --quiet -ex 'set confirm off' -ex "save gdb-index $DESTDIR" -ex quit 't2' && test -f t2.gdb-index && objcopy --add-section '.gdb_index=t2.gdb-index' --set-section-flags '.gdb_index=readonly' 't2' 't2' && rm -f t2.gdb-index || true
gcc first.o all -o first
gcc: error: all: No such file or directory
make: *** [first] Error 1
19:54:26: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project t2 (kit: Desktop Qt 5.2.0 GCC 32bit)
When executing step 'Make'
19:54:26: Elapsed time: 00:05.


BTW, the clock is wrong, just ran the compiler with above result

wysota
6th March 2015, 10:11
Do you have any extra build steps in your config?

anda_skoa
6th March 2015, 11:29
The problem seems to come from the filename "first"
The Makefile has a standard target called "first", this seems to lead to a mixup with the rule for bulding first.o

Try renaming first.h/.cpp to something else.

Cheers,
_

sundbergad
6th March 2015, 13:34
Hmmm, shall test to remove/rename first

result
Tested on my mac - same problem.
Tested on my Linux - fixed problem

Interesting, but not surprised, Linux is much easier to compile in (to get it to compile/working) than in my mac.

Well ever the less, learned that I can't use the name first, or any other name that make uses.

Thanks for the assistanse/help
cheers and and have a nice weekend with happy coding to U