PDA

View Full Version : why i am getting errors:: undefined reference to



arunchaudhary1983
22nd October 2007, 08:07
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

wysota
22nd October 2007, 08:10
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.

arunchaudhary1983
22nd October 2007, 08:30
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....

jpn
22nd October 2007, 08:39
See Qt Tutorial - Chapter 1: Hello, World! - Compiling (http://doc.trolltech.com/3.3/tutorial1-01.html#compiling)

arunchaudhary1983
22nd October 2007, 09:51
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

wysota
22nd October 2007, 10:33
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