Article View: comp.windows.interviews
Article #996Re: Graphics library problems
From: Tom Tkacik CS/50
Date: Fri, 26 Apr 1991 21:16
Date: Fri, 26 Apr 1991 21:16
83 lines
3439 bytes
3439 bytes
In article <9104262050.AA13330@sleepy.cs.wisc.edu>, locascio@CS.WISC.EDU
(James Locascio) writes:
|> Hi. I'm trying to link in the graphics library to an application I
am develop-
|> ing. The code compiles correctly, but every time I try to link, I get and
|> error message stating:
|>
|> ld: Undefined symbol
|> Graphic::p
|> Graphic::identity
|> Graphic::painters
|> Graphic::caching
I had the same problem.
|> When I look at the file "base.h", I notice that these variables are all
|> declared "static" in the Graphic definition. Could this be causing the
|> problems?
Yes. Another file is rasterrect.c. It contains a static member ColorMaker.
|> I tried changing these variables so that they were not static and
re-compiling
|> the library. My code then compiled and linked, but gave me a bus error when
|> I tried to run, so I am assuming that this "fix" is inadequate.
Not a good idea. Static as used in these files means that there is a single
copy of that variable for every instance of that class. You changed it so
that each has its own copy.
Unfortunately, this is only a declaration of that variable. You also need to
define it somewhere. It should be defined in the same file as the member
function definitions, (namely base.c and rasterrect.c).
|> Does anyone have any suggestions? I am using a SUN 4 workstation. I
suspect
|> that my compilation/linking options aren't working as I expect, but I don't
|> know where to start to find a fix.
I made the following changes, and things now seem to work. I even sent them
to the authors and was told that it was the right thing to do.
Hopefully, it will appear with the next set of official patches.
In the mean time, this should do the job for you.
*** base.c~ Sat Jan 5 19:59:45 1991
--- base.c Thu Apr 25 15:09:10 1991
***************
*** 31,36 ****
--- 31,42 ----
#include <InterViews/Graphic/hash.h>
#include <InterViews/Graphic/util.h>
+ // define static class members
+ GraphicToPainter* Graphic::painters;
+ Painter* Graphic::p;
+ Transformer* Graphic::identity; /* identity matrix */
+ boolean Graphic::caching; /* state of bounding box caching */
+
Graphic& Graphic::operator =(Graphic& p) {
SetColors(p.GetFgColor(), p.GetBgColor());
FillBg(p.BgFilled());
*** rasterrect.c~ Wed Jan 23 14:37:04 1991
--- rasterrect.c Thu Apr 25 15:11:01 1991
***************
*** 29,34 ****
--- 29,37 ----
#include <InterViews/Graphic/grclasses.h>
#include <InterViews/Graphic/rasterrect.h>
+ //define static class members
+ class ColorMaker* RasterRect::colorMaker;
+
/*****************************************************************************/
class ColorMaker {
--
Tom Tkacik tkacik@hobbes.cs.gmr.com
GM Research Labs tkacik@kyzyl.mi.org
"If you can't stand the bugs, stay out of the roach-motel."
---Ron Guilmette
Technical Details
Message-ID:
<51755@rphroy.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!rphroy!hobbes.cs.gmr.com!tkacikReferences:
<9104262050.AA13330@sleepy.cs.wisc.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!rphroy!hobbes.cs.gmr.com!tkacik From: tkacik@hobbes.cs.gmr.com (Tom Tkacik CS/50) Newsgroups: comp.windows.interviews Subject: Re: Graphics library problems Message-ID: <51755@rphroy.UUCP> Date: 26 Apr 91 21:16:53 GMT References: <9104262050.AA13330@sleepy.cs.wisc.edu> Sender: news@rphroy.UUCP Reply-To: tkacik@hobbes.cs.gmr.com (Tom Tkacik CS/50) Lines: 83 Nntp-Posting-Host: hobbes.cs.gmr.com