Jump to content
  • Advertisement
Sign in to follow this  
SirGorthon

Linker Woes :(

This topic is 5037 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Howdy! I was writing a class that does trig functions. For each of the trig functions I have a version that takes an int, and a version that takes a float. The sin(float) and cos(float) work, but not any of the other four, which when called give me: DerMain.obj : error LNK2001: unresolved external symbol "public: float __thiscall P3D::tan(float)" (?tan@P3D@@$$FQAEMM@Z) DerMain.obj : error LNK2001: unresolved external symbol "public: float __thiscall P3D::tan(int)" (?tan@P3D@@$$FQAEMH@Z) DerMain.obj : error LNK2001: unresolved external symbol "public: float __thiscall P3D::cos(int)" (?cos@P3D@@$$FQAEMH@Z) DerMain.obj : error LNK2001: unresolved external symbol "public: float __thiscall P3D::sin(int)" (?sin@P3D@@$$FQAEMH@Z) C:\Fappo\Pogo\Debug\Pogo.exe : fatal error LNK1120: 4 unresolved externals I put this in P3D.h
	inline float sin(float d);
	inline float cos(float d);
	inline float tan(float d);
	inline float sin(int d);
	inline float cos(int d);
	inline float tan(int d);

And this in P3D.cpp
inline float P3D::sin(float d)
{return SIN[angle(d)];}

inline float P3D::cos(float d)
{return COS[angle(d)];}

inline float P3D::tan(float d)
{return TAN[angle(d)];}

inline float P3D::sin(int d)
{return SIN[angle(d)];}

inline float P3D::cos(int d)
{return COS[angle(d)];}

inline float P3D::tan(int d)
{return TAN[angle(d)];}

(SIN COS and TAN are arrays that are made in P3D's constructor, and angle(int) and angle(float) return a coterminal angle between 0 and 256) Anywho, my question is: why do the sin(float) and cos(float) work, but the other four don't?

Share this post


Link to post
Share on other sites
Advertisement
Try removing the inline from the definitions. If you have them declared inline, the compiler may not actually generate object code for them. inline only makes sense for functions where you define the function in the header, or private implementation functions.

Share this post


Link to post
Share on other sites
Quote:
Original post by SirGorthon
Howdy!
I was writing a class that does trig functions. For each of the trig functions I have a version that takes an int, and a version that takes a float.

The sin(float) and cos(float) work, but not any of the other four, which when called give me:
DerMain.obj : error LNK2001: unresolved external symbol "public: float __thiscall P3D::tan(float)" (?tan@P3D@@$$FQAEMM@Z)
DerMain.obj : error LNK2001: unresolved external symbol "public: float __thiscall P3D::tan(int)" (?tan@P3D@@$$FQAEMH@Z)
DerMain.obj : error LNK2001: unresolved external symbol "public: float __thiscall P3D::cos(int)" (?cos@P3D@@$$FQAEMH@Z)
DerMain.obj : error LNK2001: unresolved external symbol "public: float __thiscall P3D::sin(int)" (?sin@P3D@@$$FQAEMH@Z)
C:\Fappo\Pogo\Debug\Pogo.exe : fatal error LNK1120: 4 unresolved externals

I put this in P3D.h
*** Source Snippet Removed ***

And this in P3D.cpp
*** Source Snippet Removed ***

(SIN COS and TAN are arrays that are made in P3D's constructor, and angle(int) and angle(float) return a coterminal angle between 0 and 256)

Anywho, my question is: why do the sin(float) and cos(float) work, but the other four don't?


This is the problem. Here is your new .h file:

class P3D
{
public:
inline float sin(float d);
inline float cos(float d);
inline float tan(float d);
inline float sin(int d);
inline float cos(int d);
inline float tan(int d);
private:
};




It needs to be in a class! I hope this helps you.

- Drew

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!