Results 1 to 7 of 7

Thread: Can't Compile on Ubuntu Linux

  1. #1
    Join Date
    Apr 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Can't Compile on Ubuntu Linux

    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

  2. #2
    Join Date
    Feb 2008
    Posts
    491
    Thanks
    12
    Thanked 142 Times in 135 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Can't Compile on Ubuntu Linux

    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 is a link to the Qt qmake manual.

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

  3. #3
    Join Date
    Apr 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Can't Compile on Ubuntu Linux

    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#

  4. #4
    Join Date
    Feb 2008
    Posts
    491
    Thanks
    12
    Thanked 142 Times in 135 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Can't Compile on Ubuntu Linux

    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:
    Qt Code:
    1. QTDIR=/opt/qtsdk-2010.02/qt
    2. PATH=$QTDIR/bin:$PATH
    3. export QTDIR PATH
    To copy to clipboard, switch view to plain text mode 
    HTH
    Last edited by norobro; 9th April 2010 at 16:54. Reason: correct typo

  5. #5
    Join Date
    Apr 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Can't Compile on Ubuntu Linux

    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
    Attached Files Attached Files

  6. #6
    Join Date
    Feb 2010
    Location
    Pennsylvania, USA
    Posts
    36
    Thanks
    9
    Thanked 3 Times in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Can't Compile on Ubuntu Linux

    Add
    Qt Code:
    1. #include <cstdlib>
    To copy to clipboard, switch view to plain text mode 
    to your includes, and see if that fixes the errors regarding "abort" and "exit".

  7. #7
    Join Date
    Apr 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Can't Compile on Ubuntu Linux

    That worked! Thanks for your help; much appreciated. . .

Similar Threads

  1. Replies: 3
    Last Post: 18th February 2010, 16:43
  2. Replies: 10
    Last Post: 13th November 2009, 19:31
  3. Replies: 0
    Last Post: 4th November 2009, 07:45
  4. Compile error with qtopia-opensrouce-4.3.2 on Ubuntu.
    By JPPoulin in forum Qt Programming
    Replies: 0
    Last Post: 6th June 2009, 03:58
  5. Replies: 5
    Last Post: 6th March 2009, 09:58

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.