• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Solved Linux - Error: undefined reference to `Tile::getHeight() const'

Thaian Citizen

Hexenjäger
Joined
Apr 5, 2013
Messages
144
Solutions
4
Reaction score
17
Location
germany
Hello, when I try to compile I get the following error:

game.o: In function `Game::internalMoveCreature(Creature*, Direction, unsigned int)':
/root/****/source/game.cpp:1038: undefined reference to `Tile::getHeight() const'
/root/****/source/game.cpp:1038: undefined reference to `Tile::getHeight() const'
/root/****/source/game.cpp:1036: undefined reference to `Tile::getHeight() const'
/root/****/source/game.cpp:1040: undefined reference to `Tile::getHeight() const'
game.o: In function `Game::playerMoveCreature(unsigned int, unsigned int, Position const&, Position const&)':
/root/****/source/game.cpp:899: undefined reference to `Tile::getHeight() const'
collect2: error: ld returned 1 exit status
make[1]: *** [otserv] Error 1
make[1]: Leaving directory `/root/****/source'
make: *** [all] Error 2
******:~/****/source#

But my function getHeight() is defined properly?

Tile.cpp:
Code:
int32_t Tile::getHeight() const
{
    uint32_t height = 0;
    Item* iiItem = NULL;
    for(uint32_t i = 0; i < getThingCount(); ++i){
        iiItem = __getThing(i)->getItem();

        if(iiItem && iiItem->hasProperty(HASHEIGHT))
            ++height;
    }

    return height;
}

Tile.h:
Code:
// under this class, public
class Tile : public Cylinder
{
public:
int32_t getHeight() const;
...

game.cpp:
Code:
//this the lines calling the getHeight()
toTile = getTile(destPos);
 
    // ACERON TRYING TO IMPLEMENT STACKED BLOCK
    Tile* toPos = getTile(destPos.x, destPos.y, destPos.z);
    Tile* fromPos = getTile(currentPos.x, currentPos.y, currentPos.z);

    ReturnValue ret = RET_NOTPOSSIBLE;
    if(toTile != NULL){
     
        // Can't walk over items with height >= 2
        if (currentPos.z > destPos.z && toPos->getHeight() > 1);
            // not possible
        else if ((((toPos->getHeight() - fromPos->getHeight()) < 2)) ||
            (fromPos->hasHeight(3) && (currentPos.z == destPos.z)) ||
            ((currentPos.z < destPos.z) && (toPos->hasHeight(3) && (fromPos->getHeight() < 2)))) 
            ret = internalMoveCreature(creature, fromTile, toTile, flags);
    }

    if(ret != RET_NOERROR){
        if(Player* player = creature->getPlayer()){
            player->sendCancelMessage(ret);
            player->sendCancelWalk();
        }
    }


I know it's a simple misstake if there's one..
But I can't seem to find it
Your help is appreciated :)
 
Last edited:
Nope :(

I had it at uint32_t before, produced same error. Now even changed it back to that and tried again, still produces same error..

Im getting frustrated everything seems right, like its a false error ??...
 
so how would I check that/resolve that, I tried deleting, just left makefile.in and makefile.am there, because it wouldnt compile without.. after that it produced same error
 
First try to build your project in a new location, if that doesn't work, check the makefile if you link libraries in the correct order
 
I did try to build it in a new location...

All I did was add an additional function to tile.cpp tile.h
I don't see how that simple thing can require to change the linking order :S

I really don't get behind that linking stuff... I mean I opened the makefile 1k lines and I don't even know what I would do there lol

edit: is there any way for me to provide more code/ info for you to detect the problem??
 
Back
Top