locascio@CS.WISC.EDU (James Locascio) (04/27/91)
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 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? 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. 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. Thanks, Jim Locascio (locascio@cs.wisc.edu)
tkacik@hobbes.cs.gmr.com (Tom Tkacik CS/50) (04/27/91)
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