Sign in to follow this  

Linker Woes :(

This topic is 4736 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
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

This topic is 4736 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this