Devin Carless
2002-02-08 20:55:05 UTC
Hello all,
Of recent, as a way of doing something useful with my time, I've begun to
teach myself C++. (Those of you wincing already need read no further.)
The only book available is eight years out of date and has no index to speak
of. Despite this and other travails, I've managed to defeat just about
every 'gotcha!' the language, libraries and compiler have thrown at me
so far.
Until the other day. I started getting linker errors that I simply could
not explain. They go away when I do things that, by all rights, shouldn't
do anything. So although I've managed to defeat these entymological
horrors, I have the feeling they're symptoms of a deeper problem, one
that I'm at a loss to diagnose or fix.
Specifics: I'm using the Bloodshed Dev-C++ 4 IDE and MinGW
2.95.2-1 MSVCRT on Windows98. The project I'm working on is
a fairly simple game, based on the old Lost Worlds booklets. (If you
don't know those, it's kind of a cross between Battleship and World
Fantasy Wrestling.)
The problem is that I keep getting undefined references to functions
in the source code, even though functions similar in all but name pass
unscathed. These disappear when I move the function definition from
the .cpp to the .h.
A virtual deconstructor caused an undefined reference error.. until
the declaration was moved from the bottom of the public: section of the
class to third, right after the constructors. What's more, this fix got rid
of another undefined reference error in the same class. I've also had
similar problems with the inline statement and a typedef.
As you can see, I've managed to get rid of these annoying errors, at the
cost of making my code less readable. But I'm concerned that there's
something bigger going on - all of these errors went away when perfectly
good C++ code was cosmetically changed. So whatever the matter is,
if there is a common cause, it's beyond my ken. (Anything inside the linker
may as well be voodoo to me: 'tlink -o -v blackcockerel.o'.)
I've trawled the Net back and forth looking for any sort of explanation.
It's probably not the compiler; the errors persist when I compile as Cygwin
(an option Dev-C++ gives you.) All the problems other people seem to be
having are with linking to libraries. My problem is linking to functions
the compiler recognizes and has passed on as valid to the linker.
I always get the hard ones.
--Devin Carless
(P.S. Due to some sort of aberration with my usual mail server, I'm sending
this through my Yahoo account. I'm still receiving messages perfectly well,
but get errors when I try to send. So, in the assumption that the problem
will eventually be fixed, please send any mail to me at:
***@calum.csclub.uwaterloo.ca
Thank you. And please don't flame me for having a Yahoo account. I
haven't used it in months, I swear.)
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
Of recent, as a way of doing something useful with my time, I've begun to
teach myself C++. (Those of you wincing already need read no further.)
The only book available is eight years out of date and has no index to speak
of. Despite this and other travails, I've managed to defeat just about
every 'gotcha!' the language, libraries and compiler have thrown at me
so far.
Until the other day. I started getting linker errors that I simply could
not explain. They go away when I do things that, by all rights, shouldn't
do anything. So although I've managed to defeat these entymological
horrors, I have the feeling they're symptoms of a deeper problem, one
that I'm at a loss to diagnose or fix.
Specifics: I'm using the Bloodshed Dev-C++ 4 IDE and MinGW
2.95.2-1 MSVCRT on Windows98. The project I'm working on is
a fairly simple game, based on the old Lost Worlds booklets. (If you
don't know those, it's kind of a cross between Battleship and World
Fantasy Wrestling.)
The problem is that I keep getting undefined references to functions
in the source code, even though functions similar in all but name pass
unscathed. These disappear when I move the function definition from
the .cpp to the .h.
A virtual deconstructor caused an undefined reference error.. until
the declaration was moved from the bottom of the public: section of the
class to third, right after the constructors. What's more, this fix got rid
of another undefined reference error in the same class. I've also had
similar problems with the inline statement and a typedef.
As you can see, I've managed to get rid of these annoying errors, at the
cost of making my code less readable. But I'm concerned that there's
something bigger going on - all of these errors went away when perfectly
good C++ code was cosmetically changed. So whatever the matter is,
if there is a common cause, it's beyond my ken. (Anything inside the linker
may as well be voodoo to me: 'tlink -o -v blackcockerel.o'.)
I've trawled the Net back and forth looking for any sort of explanation.
It's probably not the compiler; the errors persist when I compile as Cygwin
(an option Dev-C++ gives you.) All the problems other people seem to be
having are with linking to libraries. My problem is linking to functions
the compiler recognizes and has passed on as valid to the linker.
I always get the hard ones.
--Devin Carless
(P.S. Due to some sort of aberration with my usual mail server, I'm sending
this through my Yahoo account. I'm still receiving messages perfectly well,
but get errors when I try to send. So, in the assumption that the problem
will eventually be fixed, please send any mail to me at:
***@calum.csclub.uwaterloo.ca
Thank you. And please don't flame me for having a Yahoo account. I
haven't used it in months, I swear.)
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com