Results 1 to 6 of 6

Thread: why i am getting errors:: undefined reference to

  1. #1
    Join Date
    Oct 2007
    Posts
    3
    Qt products
    Qt3 Qt/Embedded
    Platforms
    Unix/X11

    Default why i am getting errors:: undefined reference to

    hello,
    please guide me for the following errors....
    why i am getting these....
    how to overcome these errors...


    [root@localhost DATASERVER]# g++ -o p1 -L/usr/lib -lpthread main.cpp DataServerPort.o DataServerLog.o
    In file included from /usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/backward/iostream.h:31,
    from main.cpp:3:
    /usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.
    In file included from main.cpp:6:
    DataServerPort.h:67:7: warning: no newline at end of file
    In file included from main.cpp:8:
    DataServerLog.h:31:2: warning: no newline at end of file
    /tmp/ccJSnhQz.o: In function `__static_initialization_and_destruction_0(int, int)':
    main.cpp:(.text+0x5b): undefined reference to `QString::QString(char const*)'
    /tmp/ccJSnhQz.o: In function `main':
    main.cpp:(.text+0x121): undefined reference to `QString::QString(char const*)'
    /tmp/ccJSnhQz.o: In function `QString::~QString()':
    main.cpp:(.gnu.linkonce.t._ZN7QStringD1Ev+0x1d): undefined reference to `QString::shared_null'
    main.cpp:(.gnu.linkonce.t._ZN7QStringD1Ev+0x2e): undefined reference to `QStringData::deleteSelf()'
    DataServerPort.o: In function `DataServerPort::initializeDataServerPort(QString& )':
    DataServerPort.cpp:(.text+0x43e): undefined reference to `QString::QString(char const*)'
    DataServerPort.cpp:(.text+0x450): undefined reference to `QString::stripWhiteSpace() const'
    DataServerPort.cpp:(.text+0x465): undefined reference to `QString::operator=(QString const&)'
    DataServerPort.cpp:(.text+0x4b9): undefined reference to `QString::operator=(QString const&)'
    DataServerPort.o: In function `QString::operator char const*() const':
    DataServerPort.cpp:(.gnu.linkonce.t._ZNK7QStringcv PKcEv+0xd): undefined reference to `QString::ascii() const'
    DataServerPort.o: In function `operator+(QString const&, QString const&)':
    DataServerPort.cpp:(.gnu.linkonce.t._ZplRK7QString S1_+0x15): undefined reference to `QString::QString(QString const&)'
    DataServerPort.cpp:(.gnu.linkonce.t._ZplRK7QString S1_+0x27): undefined reference to `QString::operator+=(QString const&)'
    DataServerLog.o: In function `DataServerLog::clearDataLogFile()':
    DataServerLog.cpp:(.text+0x88): undefined reference to `QString::QString(char const*)'
    DataServerLog.cpp:(.text+0x9a): undefined reference to `QString::operator+=(QString const&)'
    DataServerLog.cpp:(.text+0xa5): undefined reference to `QString::ascii() const'
    DataServerLog.o: In function `DataServerLog::writeTimeStamp()':
    DataServerLog.cpp:(.text+0x1a8): undefined reference to `QString::ascii() const'
    DataServerLog.o: In function `DataServerLog::writeDataLog(QString)':
    DataServerLog.cpp:(.text+0x26f): undefined reference to `QString::ascii() const'
    DataServerLog.cpp:(.text+0x292): undefined reference to `QString::ascii() const'
    DataServerLog.o: In function `DataServerLog::writeDataLog(char*, int)':
    DataServerLog.cpp:(.text+0x2e7): undefined reference to `QString::ascii() const'
    DataServerLog.o:DataServerLog.cpp:(.text+0x35d): more undefined references to `QString::ascii() const' follow
    DataServerLog.o: In function `DataServerLog::DataServerLog(QString)':
    DataServerLog.cpp:(.text+0x3ca): undefined reference to `QString::operator=(QString const&)'
    DataServerLog.o: In function `DataServerLog::DataServerLog(QString)':
    DataServerLog.cpp:(.text+0x416): undefined reference to `QString::operator=(QString const&)'
    DataServerLog.o: In function `QString::QString()':
    DataServerLog.cpp:(.gnu.linkonce.t._ZN7QStringC1Ev +0x7): undefined reference to `QString::shared_null'
    DataServerLog.cpp:(.gnu.linkonce.t._ZN7QStringC1Ev +0x10): undefined reference to `QString::makeSharedNull()'
    DataServerLog.cpp:(.gnu.linkonce.t._ZN7QStringC1Ev +0x1a): undefined reference to `QString::shared_null'
    collect2: ld returned 1 exit status

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: why i am getting errors:: undefined reference to

    Please use qmake to compile your applications. Qt requires a number of defines set and qmake takes care of it so that you don't have to use -D, -L and -l and you forgot to use these.

  3. #3
    Join Date
    Oct 2007
    Posts
    3
    Qt products
    Qt3 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: why i am getting errors:: undefined reference to

    hi,
    can u please tell me the steps how to compile a program and linking qt-3.3 library while compiling.....
    I am not using makefile for compiling....

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: why i am getting errors:: undefined reference to

    J-P Nurmi

  5. #5
    Join Date
    Oct 2007
    Posts
    3
    Qt products
    Qt3 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: why i am getting errors:: undefined reference to

    thanks for providing me that tutorial ...... but I want to state that I am working on vi editor and currently not using makefile for compiling my code......
    I am testimg my code .....by just linking lpthread library and qt library for compilation......
    but when i use this command :::::::::::::::::;

    g++ -o p1 -L/usr/lib -lpthread -L/usr/lib/qt-3.3 -lqt DataServerLog.o DataServerPort.o main.cpp.....

    it is giving me error::::::::::
    /usr/bin/ld: cannot find -lqt
    collect2: ld returned 1 exit status
    ....

    Also I am linking two libraries i.e. lpthread and qt at a same time.....Is it possible?????????
    So if there is any mistake in my compilation command please update me for that....

    Also please tell me how to compile without making a .project file because i have no idea about project file.....

    thanks

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: why i am getting errors:: undefined reference to

    Please use qmake to generate a makefile and run make to compile the code. Qt needs quite complex compilation commands and external tools, thus typing them by hand is really not advised. If you insist on that, please use qmake to generate a makefile for a simple project and learn the commands you need to type from the makefile.

    If you want a project file, run qmake -project

Similar Threads

  1. MS Sql native driver??
    By LordQt in forum Qt Programming
    Replies: 4
    Last Post: 9th October 2007, 14:41
  2. error undefined reference ...............
    By amit_pansuria in forum Qt Programming
    Replies: 2
    Last Post: 8th June 2007, 15:28
  3. how to correctly compile threads support?
    By srhlefty in forum Installation and Deployment
    Replies: 9
    Last Post: 25th June 2006, 20:15
  4. Strange error while using Q3Canvas
    By Kapil in forum Newbie
    Replies: 13
    Last Post: 15th June 2006, 20:36

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.