[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Problems subclassing from Agent2D (hello-world app)
From: |
Ken Cline |
Subject: |
Re: Problems subclassing from Agent2D (hello-world app) |
Date: |
Thu, 17 Jun 1999 16:39:09 -0400 (EDT) |
Paul,
I don't know if this is it, but in some places you have
"Agent2D" and in other places "Agent2d" (i.e. lower case
`d'). Is that correct or a typo?
Ken.
On Thu, 17 Jun 1999, Paul Box wrote:
> Hello Group
>
> Here is the problem that I'm having. I have some code that I am
> trying to update. As the code involves a number of agents moving
> around on an object dervived from a Discrete2d, I decided that it
> would be well to rewrite the agents so that they are subclassed
> fromAgent2D, a class in Barry M's hello-world application. The agents
> originally were derived from SwarmObjects, so I figured that deriving
> them from Agent2D's should present no major problems, and make the
> agents more "standardized"(the Agent2D is derived from a swarmobject
> itself, with just a few funcions added on).
>
> Originially, the agents, called "Boats", were declared in Boat.h as
> such:
>
> #import <objectbase.h>
> #import <objectbase/SwarmObject.h>
>
> @interface Boat: SwarmObject { ....
>
>
> I changed the header file with the following lines:
>
> #import "Agent2D.h"
>
> @interface Boat: Agent2d { ...
>
>
> And replaced some of the internal functions of the Boat with calls to
> functions that it inherited from being an Agent2D.
>
> Agent2D.h has the following lines:
>
> #import <objectbase.h>
> #import <objectbase/SwarmObject.h>
>
> @interface Agent2D: SwarmObject { ...
>
>
>
> The code seems to parse fine, but after the object files are built, I
> get the following error in linking:
>
>
> franklin:~/swarm/projects/floatspaceF> make
> gcc -c -Wno-import -g -O2 -D_GNU_SOURCE -I/usr/local/include Boat.m
> gcc -c -Wno-import -g -O2 -D_GNU_SOURCE -I/usr/local/include
> AnchorModelSwarm.m
> /usr/local/bin/libtool-swarm --mode link gcc -g -O2 -L/usr/local/lib
> -Wl,-rpath /usr/local/lib -L/usr/local/lib -Wl,-rpath
> /usr/local/lib -L/usr/local/lib -Wl,-rpath /usr/local/lib -L/usr/lib
> -Wl,-rpath /usr/lib -L/usr/X11R6/lib -o floatspace main.o Boat.o
> AnchorModelSwarm.o AnchorObserverSwarm.o Cell.o CellSurface.o
> DataFile.o Eneighbor.o CellProbe.o SeaBug.o DataFileSwarm.o -lspace
> -lanalysis -lsimtools -lsimtoolsgui -ltkobjc -ltclobjc -lactivity
> -lrandom -lobjectbase -lcollections -ldefobj -lmisc -lBLT -ltk8.0
> -ltcl8.0 -lpng -lz -lffi -lXpm -lX11 -lm -lobjc -ldl
> gcc -g -O2 -L/usr/local/lib -Wl,-rpath /usr/local/lib -L/usr/local/lib
> -Wl,-rpath /usr/local/lib -L/usr/local/lib -Wl,-rpath /usr/local/lib
> -L/usr/lib -Wl,-rpath /usr/lib -L/usr/X11R6/lib -o floatspace main.o
> Boat.o AnchorModelSwarm.o AnchorObserverSwarm.o Cell.o CellSurface.o
> DataFile.o Eneighbor.o CellProbe.o SeaBug.o DataFileSwarm.o -lspace
> -lanalysis -lsimtools -lsimtoolsgui -ltkobjc -ltclobjc -lactivity
> -lrandom -lobjectbase -lcollections -ldefobj -lmisc -lBLT -ltk8.0
> -ltcl8.0 -lpng -lz -lffi -lXpm -lX11 -lm -lobjc -ldl
> Boat.o: In function `_i_Boat__step':
> /home/sanduku/swarm/projects/floatspaceF/Boat.m:27: undefined
> reference to `__objc_class_name_Agent2d'
> make: *** [floatspace] Error 1
>
>
> The offending lines of the code in Boat.m read:
>
> for (jamii=0; jamii < [[anchorSpace getBoatList] getCount];
> jamii++){
> otherBoat = [[anchorSpace getBoatList] atOffset: jamii];
> :line 27-> thatDist = [self getDistanceTo: otherBoat];
> if ((int) thatDist){
> sumAnnoyance += [otherBoat getOffensiveness] *
> [self getSensitivity] / thatDist;
> weightX += [otherBoat getXcoord] * [otherBoat
> getOffensiveness];
> weightY += [otherBoat getYcoord] * [otherBoat
> getOffensiveness];
> sumWeight += [otherBoat getOffensiveness];
> }
>
> When I comment out the offending line, I get the same error message at
> the next place in the code where a request is made to "otherBoat".
>
> This code works fine when Boat is derived directly from a SwarmObject.
> The message "undefined reference to '__objc_class_name_Agent2D'"
> doesn't make sense to me. Why would I get that if I have declared and
> included Agent2D in the code?
>
> Any help is appreciated
>
>
> --
> //////////////////////////////////////////////////
> // Dr. Paul Box
> // Dept of Geography and Earth Resources
> // UMC 5240
> // Utah State University http://www.nr.usu.edu/~sanduku
> // Logan, UT 84321 Phone: 435-797-2546
> //////////////////////////////////////////////////
>
> * If Elvis was so great, why was he buried in the back yard like a
> * hamster?
>
> ==================================
> Swarm-Support is for discussion of the technical details of the day
> to day usage of Swarm. For list administration needs (esp.
> [un]subscribing), please send a message to <address@hidden>
> with "help" in the body of the message.
>
>
_________________________________________________________
Ken Cline address@hidden
SAIC VOICE (410) 571-0413
Annapolis, MD FAX (301) 261-8427
==================================
Swarm-Support is for discussion of the technical details of the day
to day usage of Swarm. For list administration needs (esp.
[un]subscribing), please send a message to <address@hidden>
with "help" in the body of the message.