PDA

View Full Version : Can't Compile on Ubuntu Linux



mpauley
9th April 2010, 14:51
Hi,

I need to compile a program (dnaToProtein.cpp) for a project that I am working on. (I did not write the program but downloaded it off the web.) The program is written in C++ and uses the Nokia Qt libraries. I have downloaded and installed the Qt SDK for Linux/X11 32-bit onto my Ubuntu (9.10; 32-bit) Linux machine. However, I am unable to compile the program. I have tried both the following:
g++ dnaToProtein.cpp
and
g++ -L/opt/qtsdk-2010.02/qt/include/QtCore dnaToProtein.cpp
(/opt/qtsdk-2010.02/qt/include/QtCore is where the installer placed QCoreApplication, etc.)

Error messages are listed below. Note that program has the following #include statements:
#include <QCoreApplication>
#include <QString>
#include <QStringList>
#include <QTextStream>
#include <QFile>
#include <iostream>
#include "dnaToProtein.h"

Any help would be greatly appreciated.

Error Messages:
dnaToProtein.cpp:20:28: error: QCoreApplication: No such file or directory
dnaToProtein.cpp:21:19: error: QString: No such file or directory
dnaToProtein.cpp:22:23: error: QStringList: No such file or directory
dnaToProtein.cpp:23:23: error: QTextStream: No such file or directory
dnaToProtein.cpp:24:17: error: QFile: No such file or directory
In file included from dnaToProtein.cpp:26:
dnaToProtein.h:23: error: ‘QString’ does not name a type
dnaToProtein.h:27: error: ‘QString’ does not name a type
dnaToProtein.h:31: error: ‘QChar’ does not name a type
dnaToProtein.h:32: error: ‘QString’ was not declared in this scope
dnaToProtein.h:33: error: ‘QString’ was not declared in this scope
dnaToProtein.h:35: error: ‘QFile’ has not been declared
dnaToProtein.h:36: error: ‘QFile’ has not been declared
dnaToProtein.h:37: error: ‘QString’ does not name a type
dnaToProtein.h:39: error: ‘QString’ does not name a type
dnaToProtein.h:40: error: ‘QString’ was not declared in this scope
dnaToProtein.h:41: error: ‘QChar’ was not declared in this scope
dnaToProtein.h:42: error: ‘QString’ does not name a type
dnaToProtein.h:43: error: ‘QString’ does not name a type
dnaToProtein.h:45: error: variable or field ‘writeLogfile’ declared void
dnaToProtein.h:45: error: ‘QString’ was not declared in this scope
dnaToProtein.h:47: error: ‘QString’ does not name a type
dnaToProtein.h:77: error: expected constructor, destructor, or type conversion before ‘<’ token
dnaToProtein.h:78: error: expected constructor, destructor, or type conversion before ‘<’ token
dnaToProtein.h:79: error: expected constructor, destructor, or type conversion before ‘<’ token
dnaToProtein.h:80: error: expected constructor, destructor, or type conversion before ‘<’ token
dnaToProtein.h:81: error: expected constructor, destructor, or type conversion before ‘<’ token
dnaToProtein.h:82: error: expected constructor, destructor, or type conversion before ‘<’ token
dnaToProtein.cpp:29: error: ‘QChar’ does not name a type
dnaToProtein.cpp:58: error: redefinition of ‘bool isStartCodon’
dnaToProtein.h:32: error: ‘bool isStartCodon’ previously defined here
dnaToProtein.cpp:58: error: ‘QString’ was not declared in this scope
dnaToProtein.cpp:65: error: redefinition of ‘bool isStopCodon’
dnaToProtein.h:33: error: ‘bool isStopCodon’ previously defined here
dnaToProtein.cpp:65: error: ‘QString’ was not declared in this scope
dnaToProtein.cpp:72: error: redefinition of ‘bool isBaseCharacter’
dnaToProtein.h:41: error: ‘bool isBaseCharacter’ previously defined here
dnaToProtein.cpp:72: error: ‘QChar’ was not declared in this scope

norobro
9th April 2010, 16:02
qmake is a tool that helps simplify the build process for development project across different platforms. qmake automates the generation of Makefiles so that only a few lines of information are needed to create each Makefile.

Here (http://doc.trolltech.com/4.6/qmake-manual.html) is a link to the Qt qmake manual.

Try these steps in a terminal:
cd to the directory containing your source code
type: qmake -project
type: qmake
type: make
That should generate an executable file with the same name as the directory.

mpauley
9th April 2010, 16:24
Hi,

Thanks for your response. I tried what you suggested but unfortunately I get exactly the same results as before (below).

root@mpauley-desktop:/home/mpauley/tmp# qmake -project
root@mpauley-desktop:/home/mpauley/tmp# qmake
root@mpauley-desktop:/home/mpauley/tmp# make
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -I. -o dnaToProtein.o dnaToProtein.cpp
dnaToProtein.cpp:20:28: error: QCoreApplication: No such file or directory
dnaToProtein.cpp:21:19: error: QString: No such file or directory
dnaToProtein.cpp:22:23: error: QStringList: No such file or directory
dnaToProtein.cpp:23:23: error: QTextStream: No such file or directory
dnaToProtein.cpp:24:17: error: QFile: No such file or directory
In file included from dnaToProtein.cpp:26:
dnaToProtein.h:23: error: ‘QString’ does not name a type
dnaToProtein.h:27: error: ‘QString’ does not name a type
dnaToProtein.h:31: error: ‘QChar’ does not name a type
dnaToProtein.h:32: error: ‘QString’ was not declared in this scope
dnaToProtein.h:33: error: ‘QString’ was not declared in this scope
dnaToProtein.h:35: error: ‘QFile’ has not been declared
dnaToProtein.h:36: error: ‘QFile’ has not been declared
dnaToProtein.h:37: error: ‘QString’ does not name a type
dnaToProtein.h:39: error: ‘QString’ does not name a type
dnaToProtein.h:40: error: ‘QString’ was not declared in this scope
dnaToProtein.h:41: error: ‘QChar’ was not declared in this scope
dnaToProtein.h:42: error: ‘QString’ does not name a type
dnaToProtein.h:43: error: ‘QString’ does not name a type
dnaToProtein.h:45: error: variable or field ‘writeLogfile’ declared void
dnaToProtein.h:45: error: ‘QString’ was not declared in this scope
dnaToProtein.h:47: error: ‘QString’ does not name a type
dnaToProtein.h:77: error: expected constructor, destructor, or type conversion before ‘<’ token
dnaToProtein.h:78: error: expected constructor, destructor, or type conversion before ‘<’ token
dnaToProtein.h:79: error: expected constructor, destructor, or type conversion before ‘<’ token
dnaToProtein.h:80: error: expected constructor, destructor, or type conversion before ‘<’ token
dnaToProtein.h:81: error: expected constructor, destructor, or type conversion before ‘<’ token
dnaToProtein.h:82: error: expected constructor, destructor, or type conversion before ‘<’ token
dnaToProtein.cpp:29: error: ‘QChar’ does not name a type
dnaToProtein.cpp:58: error: redefinition of ‘bool isStartCodon’
dnaToProtein.h:32: error: ‘bool isStartCodon’ previously defined here
dnaToProtein.cpp:58: error: ‘QString’ was not declared in this scope
dnaToProtein.cpp:65: error: redefinition of ‘bool isStopCodon’
dnaToProtein.h:33: error: ‘bool isStopCodon’ previously defined here
dnaToProtein.cpp:65: error: ‘QString’ was not declared in this scope
dnaToProtein.cpp:72: error: redefinition of ‘bool isBaseCharacter’
dnaToProtein.h:41: error: ‘bool isBaseCharacter’ previously defined here
dnaToProtein.cpp:72: error: ‘QChar’ was not declared in this scope
make: *** [dnaToProtein.o] Error 1
root@mpauley-desktop:/home/mpauley/tmp#

norobro
9th April 2010, 16:47
Sorry I didn't notice that Qt is installed in a non standard location. I have Qt on a different partition on my Debian box and this works on my machine, hopefully it will on yours:

QTDIR=/opt/qtsdk-2010.02/qt
PATH=$QTDIR/bin:$PATH
export QTDIR PATH
HTH

mpauley
9th April 2010, 17:19
Thanks again for your response. I greatly appreciate your help.

I think I'm getting closer but I'm still getting an error message (below). I've also attached the source code in the event that that might help.

root@mpauley-desktop:/home/mpauley/tmp# QTDIR=/opt/qtsdk-2010.02/qt
root@mpauley-desktop:/home/mpauley/tmp# PATH=$QTDIR/bin:$PATH
root@mpauley-desktop:/home/mpauley/tmp# export QTDIR PATH
root@mpauley-desktop:/home/mpauley/tmp# qmake -project
QFileInfo::absolutePath: Constructed with empty filename
root@mpauley-desktop:/home/mpauley/tmp# qmake
root@mpauley-desktop:/home/mpauley/tmp# make
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/opt/qtsdk-2010.02/qt/mkspecs/linux-g++ -I. -I/opt/qtsdk-2010.02/qt/include/QtCore -I/opt/qtsdk-2010.02/qt/include/QtGui -I/opt/qtsdk-2010.02/qt/include -I. -I. -o dnaToProtein.o dnaToProtein.cpp
dnaToProtein.cpp: In function ‘void myMessageOutput(QtMsgType, const char*)’:
dnaToProtein.cpp:98: error: ‘abort’ was not declared in this scope
dnaToProtein.cpp: In function ‘void writeHelpOutput()’:
dnaToProtein.cpp:692: error: ‘exit’ was not declared in this scope
dnaToProtein.cpp: In function ‘int main(int, char**)’:
dnaToProtein.cpp:794: error: ‘exit’ was not declared in this scope
make: *** [dnaToProtein.o] Error 1

TheJim01
9th April 2010, 21:45
Add
#include <cstdlib> to your includes, and see if that fixes the errors regarding "abort" and "exit".

mpauley
9th April 2010, 22:00
That worked! Thanks for your help; much appreciated. . .