473,406 Members | 2,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

[not-in-charge]

Hi,
I have looked up all the solutions for this problem, but nothing seems to
work for. I would really appreciate any help and a reason as to why this
happens...

When I complile I seem to get the following errors:

g++ -I. -g -Wall -fno-inline -c timers.cpp
g++ -I. -g -Wall -fno-inline -c tools.cpp
g++ -I. -g -Wall -fno-inline -c test-app.cpp
test-app.cpp: In member function `virtual int TestTimer3::Expire()':
test-app.cpp:63: warning: int format, handle arg (arg 3)
g++ timers.o tools.o test-app.o -o test-app
timers.o(.gnu.linkonce.d._ZTI8cTimeVal+0x8):/nfs/guest/asyed/ilenseCVS/timer
s/timers.cpp:102: undefined reference to `typeinfo for cSimTime'
timers.o(.gnu.linkonce.t._ZN8cSimTimeC2Ev+0x8): In function
`cSimTime::cSimTime[not-in-charge]()':
/nfs/guest/asyed/ilenseCVS/timers/timers.cpp:102: undefined reference to
`vtable for cSimTime'
timers.o(.gnu.linkonce.t._ZN8cSimTimeD2Ev+0xb): In function
`cSimTime::~cSimTime [not-in-charge]()':
/nfs/guest/asyed/ilenseCVS/timers/timers.cpp:262: undefined reference to
`vtable for cSimTime'
collect2: ld returned 1 exit status
make: *** [test-app] Error 1

I have the cSimTime class as a pure abstract class and use cTimeVal as
subclass implementing *all* the pure virtual functions. Here is the code:
(Note the first error comes when i am defining the first non-inline virutal
function of the timeVal class i.e. on line 102 of timers.cpp i have the
implementation of getLine())

class cSimTime{
public:
cSimTime() {};
virtual ~cSimTime() {};

//the current virtual time
virtual void getTime() = 0;

//return the current time in the cSimTime object
virtual cSimTime* returnCurrentTime()=0;

//return -1,0,1 for < == >
virtual short compareTime( cSimTime* compareWith)=0;

//add to this time object a specific # of virtual ticks
virtual void addTime(timeTicks ticks) =0;

//set time arbitrarily to the value passed
virtual void setTime(timeTicks ticks) =0;

//subtract from this time object y and return their value... return value
interpreted by implementor of subclass
virtual cSimTime* subTime(cSimTime* y) =0 ;
//generic printing funtion
virtual void print()=0;

};
/*One abstraction of the virtual time concept in the simulator
*
*For example refer to the test app.
*/
class cTimeVal: public cSimTime{

public:
cTimeVal(){};
~cTimeVal(){};

//the current virtual time
void getTime();

//return the current time in the cSimTime object
cSimTime* returnCurrentTime();

//return -1,0,1 for < == >
short compareTime(cSimTime* compareWith);

//add to this time object a specific # of virtual ticks
void addTime(timeTicks ticks);

//set time arbitrarily to the value passed
void setTime(timeTicks ticks) { tv.tv_sec = ticks;};

//subtract from this time object y and return their value... return value
interpreted by implementor of subclass
cSimTime* subTime(cSimTime* y);

//printing for the timeval struct
void print(){printf("time=%ld:%06ld \n",tv.tv_sec,tv.tv_usec);};

struct timeval tv;//the concept of time for this instance
};

////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////

Please note that i am also creating inside subTime function a static
variable of type cTimeVal. I am not sure but i think this might be causing
some of the errors.

I would really appreciate if people could help me out of this.

Thanks.
Regards
Affan

Jul 22 '05 #1
8 4244
Affan Ahmed schrieb:
Hi,
I have looked up all the solutions for this problem, but nothing seems to
work for. I would really appreciate any help and a reason as to why this
happens...

When I complile I seem to get the following errors:

timers.o(.gnu.linkonce.d._ZTI8cTimeVal+0x8):/nfs/guest/asyed/ilenseCVS/timer
s/timers.cpp:102: undefined reference to `typeinfo for cSimTime'
timers.o(.gnu.linkonce.t._ZN8cSimTimeC2Ev+0x8): In function
`cSimTime::cSimTime[not-in-charge]()':
/nfs/guest/asyed/ilenseCVS/timers/timers.cpp:102: undefined reference to
`vtable for cSimTime'
[snip]
I have the cSimTime class as a pure abstract class and use cTimeVal as
subclass implementing *all* the pure virtual functions. Here is the code:
(Note the first error comes when i am defining the first non-inline virutal
function of the timeVal class i.e. on line 102 of timers.cpp i have the
implementation of getLine())
This is a linker error that belongs in a a gcc-specific newsgroup.
Short answer: check if you really defined *all* virtual functions, this
kind of error is typical for something missing there.
After adding the neccessary #includes, a dummy typedef int timeTicks,
empty non-inline definitions for the other virtuals of cTimeVal and int
main() { cTimeVal t; } the code compiles and links fine for me.
class cSimTime{
public:
cSimTime() {};
virtual ~cSimTime() {}; ^ no semicolon after member function body

[snip]
struct timeval tv;//the concept of time for this instance

^^ struct keyword not needed in C++ in variable declarations

Wild guess: the paths in your make output suggest you're working on an
NFS mounted file system; make sure the system clocks on the NFS server
and client are in sync so make can get the dependencies right, but
that's really not topical here.

Regards,
Malte
Jul 22 '05 #2
Thanks everybody.. I also found the prob.... note that my pure virtual
functions were not exactly pure... there was a space between () and =0!!!!!
gawd... this sucks.. i would have thought i would get some compiler errors
or warning s atleast!!!!
"Affan Ahmed" <as***@usc.edu> wrote in message
news:ck**********@gist.usc.edu...
Hi,
I have looked up all the solutions for this problem, but nothing seems to
work for. I would really appreciate any help and a reason as to why this
happens...

When I complile I seem to get the following errors:

g++ -I. -g -Wall -fno-inline -c timers.cpp
g++ -I. -g -Wall -fno-inline -c tools.cpp
g++ -I. -g -Wall -fno-inline -c test-app.cpp
test-app.cpp: In member function `virtual int TestTimer3::Expire()':
test-app.cpp:63: warning: int format, handle arg (arg 3)
g++ timers.o tools.o test-app.o -o test-app
timers.o(.gnu.linkonce.d._ZTI8cTimeVal+0x8):/nfs/guest/asyed/ilenseCVS/timer s/timers.cpp:102: undefined reference to `typeinfo for cSimTime'
timers.o(.gnu.linkonce.t._ZN8cSimTimeC2Ev+0x8): In function
`cSimTime::cSimTime[not-in-charge]()':
/nfs/guest/asyed/ilenseCVS/timers/timers.cpp:102: undefined reference to
`vtable for cSimTime'
timers.o(.gnu.linkonce.t._ZN8cSimTimeD2Ev+0xb): In function
`cSimTime::~cSimTime [not-in-charge]()':
/nfs/guest/asyed/ilenseCVS/timers/timers.cpp:262: undefined reference to
`vtable for cSimTime'
collect2: ld returned 1 exit status
make: *** [test-app] Error 1

I have the cSimTime class as a pure abstract class and use cTimeVal as
subclass implementing *all* the pure virtual functions. Here is the code:
(Note the first error comes when i am defining the first non-inline virutal function of the timeVal class i.e. on line 102 of timers.cpp i have the
implementation of getLine())

class cSimTime{
public:
cSimTime() {};
virtual ~cSimTime() {};

//the current virtual time
virtual void getTime() = 0;

//return the current time in the cSimTime object
virtual cSimTime* returnCurrentTime()=0;

//return -1,0,1 for < == >
virtual short compareTime( cSimTime* compareWith)=0;

//add to this time object a specific # of virtual ticks
virtual void addTime(timeTicks ticks) =0;

//set time arbitrarily to the value passed
virtual void setTime(timeTicks ticks) =0;

//subtract from this time object y and return their value... return value interpreted by implementor of subclass
virtual cSimTime* subTime(cSimTime* y) =0 ;
//generic printing funtion
virtual void print()=0;

};
/*One abstraction of the virtual time concept in the simulator
*
*For example refer to the test app.
*/
class cTimeVal: public cSimTime{

public:
cTimeVal(){};
~cTimeVal(){};

//the current virtual time
void getTime();

//return the current time in the cSimTime object
cSimTime* returnCurrentTime();

//return -1,0,1 for < == >
short compareTime(cSimTime* compareWith);

//add to this time object a specific # of virtual ticks
void addTime(timeTicks ticks);

//set time arbitrarily to the value passed
void setTime(timeTicks ticks) { tv.tv_sec = ticks;};

//subtract from this time object y and return their value... return value
interpreted by implementor of subclass
cSimTime* subTime(cSimTime* y);

//printing for the timeval struct
void print(){printf("time=%ld:%06ld \n",tv.tv_sec,tv.tv_usec);};

struct timeval tv;//the concept of time for this instance
};

//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////

Please note that i am also creating inside subTime function a static
variable of type cTimeVal. I am not sure but i think this might be causing
some of the errors.

I would really appreciate if people could help me out of this.

Thanks.
Regards
Affan

Jul 22 '05 #3
Affan Ahmed schrieb:
Thanks everybody.. I also found the prob.... note that my pure virtual
functions were not exactly pure... there was a space between () and =0!!!!!
gawd... this sucks.. i would have thought i would get some compiler errors
or warning s atleast!!!!


Out of curiosity, where exactly was that space?

struct A
{
virtual ~A() {}
virtual void f() = 0;
virtual void g()=0;
virtual void
h ( )
=
0
;
};

All of the above variations are syntactically correct declarations of
pure virtual functions.

Regards,
Malte
Jul 22 '05 #4
well mine was
virtual void getTime() =0;
and when i removed the space the same code compiled perfectly. I had thought
the same .. i.e. it is syntactically correct, but browsing over the net for
similar problem showed that these errors were for a virtual function that
was *not* implemented... Since I had all defined all function in my
subclass, the only prob that finally seemed to remain was that my base class
pure virtual func was not being interpreted as pure virtual. So I checked it
again, and found this discrepency.
I am sure if some one can shed some light on this .. it would be a good
thing to know.

thanks.

Affan
"Malte Starostik" <ma*************@t-online.de> wrote in message
news:ck*************@news.t-online.com...
Affan Ahmed schrieb:
Thanks everybody.. I also found the prob.... note that my pure virtual
functions were not exactly pure... there was a space between () and =0!!!!! gawd... this sucks.. i would have thought i would get some compiler errors or warning s atleast!!!!


Out of curiosity, where exactly was that space?

struct A
{
virtual ~A() {}
virtual void f() = 0;
virtual void g()=0;
virtual void
h ( )
=
0
;
};

All of the above variations are syntactically correct declarations of
pure virtual functions.

Regards,
Malte

Jul 22 '05 #5
Affan Ahmed wrote:
well mine was
virtual void getTime() =0;
and when i removed the space the same code compiled perfectly.


Are you sure? Could you take the file which compiles now, put _one_
space after the 'getTime()' and try to compile it again?
Or, alternatively, take the original file which does not compile
and remove _one_ space from it and compile?

If space really causes the problem, then please post contents
of the file and output of 'g++ --version'.

(Yet, there is something strange with spaces in your original post
(and this as well). Maybe it's a problem of my newsreader, or of
your mail client, but it's weird. Maybe this is a problem?)

Thank you,
Yevgen

Jul 22 '05 #6

"Affan Ahmed" <as***@usc.edu> wrote in message
news:ck**********@gist.usc.edu...
well mine was
virtual void getTime() =0;
and when i removed the space the same code compiled perfectly. I had
thought
the same .. i.e. it is syntactically correct, but browsing over the net
for
similar problem showed that these errors were for a virtual function that
was *not* implemented... Since I had all defined all function in my
subclass, the only prob that finally seemed to remain was that my base
class
pure virtual func was not being interpreted as pure virtual. So I checked
it
again, and found this discrepency.
I am sure if some one can shed some light on this .. it would be a good
thing to know.


Isn't this one of those problems that goes away when you force a
recompilation? Adding or removing spaces wasn't the fix. It was the fact
that by changing the header file you forced a recompilation of all the
source files that needed recompiling.

john
Jul 22 '05 #7
John Harrison schrieb:
"Affan Ahmed" <as***@usc.edu> wrote in message
news:ck**********@gist.usc.edu...
well mine was
virtual void getTime() =0;
and when i removed the space the same code compiled perfectly. I had
thought
the same .. i.e. it is syntactically correct, but browsing over the net
for
similar problem showed that these errors were for a virtual function that
was *not* implemented...


Isn't this one of those problems that goes away when you force a
recompilation? Adding or removing spaces wasn't the fix. It was the fact
that by changing the header file you forced a recompilation of all the
source files that needed recompiling.


I'd very much suspect that. If it really is the space then the only
thing I can imagine is the space being some Unicode non-breaking space
char, you could check that with a hex editor...

<totally OT>
If it was the forced recompilation that fixed it, then something is
wrong with your dependency info; check your Makefile and/or run make
with verbose output to see what files it considers in its dependency
checks. But as changing the header finally resulted in a recompilation,
my guess would really be a desynced file time issue as I mentioned
earlier. Never use a source tree on NFS without NTP.
</totally OT>

Regards,
Malte
Jul 22 '05 #8
Well it is true that when i tried to recompile with a space in between ... I
didnt find any problem!... I am kinda uncomfortable with makefile and was
using another template which I tried to fill in as I thought was neccecary.
but i havent really changed the makefile as yet either. So the only
plausible thing could have been the NFS problem (which sadly i didnt really
graps). However if it was a time sync issue, then why did it ever get
corrected when i did remove the space?
Thanks any way.. as long as its not bugging me any longer.
Regards,
Affan

..

I'd very much suspect that. If it really is the space then the only
thing I can imagine is the space being some Unicode non-breaking space
char, you could check that with a hex editor...

<totally OT>
If it was the forced recompilation that fixed it, then something is
wrong with your dependency info; check your Makefile and/or run make
with verbose output to see what files it considers in its dependency
checks. But as changing the header finally resulted in a recompilation,
my guess would really be a desynced file time issue as I mentioned
earlier. Never use a source tree on NFS without NTP.
</totally OT>

Regards,
Malte

Jul 22 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Fabian Knopf | last post by:
Hi @ll, when i want to set the PrefetchSize on my database this setting will not be set. DB2 shell says that the command is successfull but when i list my details with. list tablespaces show...
11
by: ynott | last post by:
Novice here obviously. Anyway, I'm a bit confused about how to approach this. I have a query against a table that I'm trying to create. I'm trying to view all streets.type values that are null,...
1
by: Bimal | last post by:
Hi, I upgraded my gcc from 2.95 to 3.3. When I compile some projects I get error messages saying... /usr/local/include/c++/3.3/ctime:68: error: `tm' not declared...
31
by: Randy Yates | last post by:
When I try fprintf(file, "Report of File %s\n", sMF->fileName); I get a core dump. This works fine if fprintf is changed to sprintf and a string buffer used instead as the first parameter. ...
1
by: Tamas Demjen | last post by:
I started to experiment with VC++ 2005 Beta1. So far everything went fine, and already have a working project, but soon I realized that the compiler was ancient (not supporting half of the C++/CLI...
3
by: Rajesh Kumar Mallah | last post by:
Hi, Looks like alter table does not tells about the indexes it dropped PG version: 7.4.3 Regds mallah.
14
by: NormD | last post by:
We have a client-server app using Web Services on an IIS machine. The trace below shows that .NET is searching around for some things (e.g., SystemDrawing.DLL and System.Drawing.EXE) and taking a...
1
by: Ike | last post by:
Why would some innodb's not take a 'no null' for a field? Has anyone experienced anything like this? -Ike
0
by: Donius | last post by:
Hello team. I'm running mysql 4.0.20-standard and i'm trying to do a query like this: INSERT IGNORE INTO `DonorPledges` ( nDonor_id, nPledgeYear, nTotalPaid, nTotalPledge ) SELECT
0
by: Derek | last post by:
I am creating an intranet using Visual Web Developer Express Edition. Everything has been working OK until yesterday when I started getting 62 messages all beginning "Could not find schema...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.