Game Development Community

Error LNK2001

by Ken Johnston · in Torque 3D Professional · 10/16/2011 (10:01 am) · 7 replies

I am completely stumped on this error i am getting. I am trying to create a new class, the .cpp compiles fine except when i try to build the complete solution i am getting this error:

1>NewPl.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall NewPl::setRenderTransform(class MatrixF const &)" (?setRenderTransform@NewPl@@MAEXABVMatrixF@@@Z)

and

1>NewPl.obj : error LNK2019: unresolved external symbol "protected: bool __thiscall NewPL::inSittingAnim(void)" (?inSittingAnim@NewPl@@IAE_NXZ) referenced in function "public: virtual bool __thiscall NewPl::onAdd(void)" (?onAdd@NewPl@@UAE_NXZ)

anyone have any advice? This new class i am trying to build is a deriviative of the Player Class

#1
10/16/2011 (9:57 pm)
Have you checked your lib paths to make sure they are correct? Also, take a look at the aiPlayer.h and aiPlayer.cpp as AIPlayer is derived from the Player class.
#2
10/16/2011 (10:33 pm)
Sounds like you have declared those 2 methods and not defined them. If you don't need to do anything special with the render transform or determining if the player is in the sitting animation, find the setRenderTransform and inSittingAnim methods in your .h file and remove them or comment them out. Otherwise give them method bodies in your .cpp file.

#3
10/17/2011 (8:31 pm)
Did you include your header anywhere in the project? If you don't throw an include in somewhere it will compile but choke on link....
#4
10/18/2011 (8:00 am)
Header is in, followed gerald's advice and i eliminated this lnk issue

NewPl.obj : error LNK2019: unresolved external symbol "protected: bool __thiscall NewPL::inSittingAnim(void)" (?inSittingAnim@NewPl@@IAE_NXZ) referenced in function "public: virtual bool __thiscall NewPl::onAdd(void)" (?onAdd@NewPl@@UAE_NXZ)

which was caused because i left a piece of this function in the header and didnt completely eliminate it as i do not need the sitting animation.

I am still trying to figure out this one though

NewPl.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall NewPl::setRenderTransform(class MatrixF const &)" (?setRenderTransform@NewPl@@MAEXABVMatrixF@@@Z)

since i am not modifying the render transform code from the player class i diffed the classes and looked specifically at this code for both the header and the .cpp and i am not seeing my error just yet....

#5
10/18/2011 (8:16 am)
It looks like you're not defining the setRenderTransform on your new player class. Since you're deriving directly from that class, you need to define it.
#6
10/18/2011 (9:41 am)
You shouldn't have to define setRenderTransform unless you are declaring it in your new class either.

I'm wondering if maybe there is a case issue. From your original error messages I see this:

protected: bool __thiscall NewPL::inSittingAnim(void)

and this:

protected: virtual void __thiscall NewPl::setRenderTransform(class MatrixF const &)

Where the first use a capital L in NewPL, and the second uses a lower case l in NewPl. It seems like you should get other errors if that is the case, but something to consider.
#7
10/18/2011 (12:41 pm)
I didnt catch that difference that may be it ill double check tonight, the .cpp compiles on its own so perhaps that is the problem with the lnk