delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/09/25/19:47:37

Date: Thu, 25 Sep 1997 16:46:54 -0700 (PDT)
Message-Id: <199709252346.QAA21216@adit.ap.net>
Mime-Version: 1.0
To: "Geoff Weber" <gweber AT tr DOT labrats DOT com>, djgpp AT delorie DOT com
From: Nate Eldredge <eldredge AT ap DOT net>
Subject: Re: "undefined reference" error with variables from templates

At 08:34  9/25/1997 -0500, Geoff Weber wrote:
>Appended are the source files I have arranged to demonstrate the problems I
am having...
>
>For those who haven't seen my previous posts, it also is included.  Can
>anyone get this source file to compile and link?  What obvious little
>glitch am I missing (I KNOW it has to be something simple)?
>
>I have built a simple source file with "vector"s that actually compiled
>and linked, even with strings.  However, even when I just merge the
>mime64.cc and mime64.h files, I STILL get these errors!!!  I have tried
>to make the variables non-static and anything else I can think of!  Here
>I typedef'd the maps without improvements.  I know there is a better
>way perhaps to write this module, but there are other modules in my
>program which depend on STL, and would be a pain to re-write.  Besides,
this way should work, unless I'm missing something... (right now I'm filled
with doubts!)...

Let me preface this message by saying that I don't use C++, and don't know
all its details, so take this with a grain of salt. Somebody correct me if
I'm wrong.

Your problem is that the program is trying to access the variables
mime64::encode, mime64::decode, and mime64::encode_string, but they don't
exist, they haven't been given definitions. This is what `undefined
reference' means. Now. I *think* that static members of a C++ class are
common to all instances of that class. Looking at your code, it seems this
is not what you want. By removing the `static''s, the code compiled fine and
ran without trouble. If you do want them static, I think you have to define
them somewhere, and initialize them with some value. However, I don't know
how that works.

Nate Eldredge
eldredge AT ap DOT net



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019