Problem with Executing Example [SOLVED]
-
I have installed QT from source and everything seems fine. This is the test code I am trying to run:
#include <QApplication>
#include <QTextEdit>int main(int argv, char **args) { QApplication app(argv, args); QTextEdit textEdit; textEdit.show(); return app.exec(); }
I saved this in a folder called QTCode. I then used qmake -project and qmake. However, when I finally call make I get the following error:
g++ -Wl,-O1 -Wl,-rpath,/usr/local/Qt-5.4.1/lib -o QTCode test.o -L/usr/local/Qt-5.4.1/lib -lQt5Gui -lQt5Core -lGL -lpthread
test.o: In functionmain': test.cpp:(.text.startup+0x27): undefined reference to
QApplication::QApplication(int&, char**, int)'
test.cpp:(.text.startup+0x31): undefined reference toQTextEdit::QTextEdit(QWidget*)' test.cpp:(.text.startup+0x39): undefined reference to
QWidget::show()'
test.cpp:(.text.startup+0x3e): undefined reference toQApplication::exec()' test.cpp:(.text.startup+0x49): undefined reference to
QTextEdit::~QTextEdit()'
test.cpp:(.text.startup+0x51): undefined reference toQApplication::~QApplication()' test.cpp:(.text.startup+0x68): undefined reference to
QApplication::~QApplication()'
test.cpp:(.text.startup+0x7b): undefined reference to `QTextEdit::~QTextEdit()'
collect2: error: ld returned 1 exit status
make: *** [QTCode] Error 1I am not sure if this is a problem with installation. I would be grateful for any help! Thank you!
-
I have installed QT from source and everything seems fine. This is the test code I am trying to run:
#include <QApplication>
#include <QTextEdit>int main(int argv, char **args) { QApplication app(argv, args); QTextEdit textEdit; textEdit.show(); return app.exec(); }
I saved this in a folder called QTCode. I then used qmake -project and qmake. However, when I finally call make I get the following error:
g++ -Wl,-O1 -Wl,-rpath,/usr/local/Qt-5.4.1/lib -o QTCode test.o -L/usr/local/Qt-5.4.1/lib -lQt5Gui -lQt5Core -lGL -lpthread
test.o: In functionmain': test.cpp:(.text.startup+0x27): undefined reference to
QApplication::QApplication(int&, char**, int)'
test.cpp:(.text.startup+0x31): undefined reference toQTextEdit::QTextEdit(QWidget*)' test.cpp:(.text.startup+0x39): undefined reference to
QWidget::show()'
test.cpp:(.text.startup+0x3e): undefined reference toQApplication::exec()' test.cpp:(.text.startup+0x49): undefined reference to
QTextEdit::~QTextEdit()'
test.cpp:(.text.startup+0x51): undefined reference toQApplication::~QApplication()' test.cpp:(.text.startup+0x68): undefined reference to
QApplication::~QApplication()'
test.cpp:(.text.startup+0x7b): undefined reference to `QTextEdit::~QTextEdit()'
collect2: error: ld returned 1 exit status
make: *** [QTCode] Error 1I am not sure if this is a problem with installation. I would be grateful for any help! Thank you!
-
Hi!
Actually, the above program is from an example:
http://doc.qt.io/qt-4.8/gettingstartedqt.htmlThis is the contents of the .pro file:
TEMPLATE = app
TARGET = QTCode
INCLUDEPATH += .
#Input
SOURCES += test.cppIn the folder I have a Makefile, a QTCode.pro file, test.cpp and test.o
Thank you!
-
Hi!
Actually, the above program is from an example:
http://doc.qt.io/qt-4.8/gettingstartedqt.htmlThis is the contents of the .pro file:
TEMPLATE = app
TARGET = QTCode
INCLUDEPATH += .
#Input
SOURCES += test.cppIn the folder I have a Makefile, a QTCode.pro file, test.cpp and test.o
Thank you!