I am creating a converter for quaternions to euler angles, I have written this code:
//(...)
/*
* Converter Includes
*/
#include "EulerAngles.h"
//(...)
static cell AMX_NATIVE_CALL n_QuatToEuler( AMX* amx, cell* params )
{
Quat q;
q.x = amx_ctof(params[1]);
q.y = amx_ctof(params[2]);
q.z = amx_ctof(params[3]);
q.w = amx_ctof(params[4]);
EulerAngles EU = Eul_FromQuat(q,params[5]);
//(...)
return 1;
}
//(...)
I included the EulerAngles.c from http://tog.acm.org/resources/GraphicsGems/gemsiv/euler_angle/ into my project, I also downloaded all the other files into my project.
When I try to compile my project I get these error messages from Visual Studio 2012:
Error 1 error LNK2001: unresolved external symbol "struct Quat __cdecl Eul_FromQuat(struct Quat,int)" (?Eul_FromQuat@@YA?AUQuat@@U1@H@Z) .\calculatorSAMP\calculatorSAMP.obj calculatorSAMP
Error 2 error LNK1120: 1 unresolved externals .\calculatorSAMP\Release\calculatorSAMP.dll calculatorSAMP
the QuadTypes.h which is included in EulerAngles.h has this code:
/**** QuatTypes.h - Basic type declarations ****/
#ifndef _H_QuatTypes
#define _H_QuatTypes
/*** Definitions ***/
typedef struct {float x, y, z, w;} Quat; /* Quaternion */
enum QuatPart {X, Y, Z, W};
typedef float HMatrix[4][4]; /* Right-handed, for column vectors */
typedef Quat EulerAngles; /* (x,y,z)=ang 1,2,3, w=order code */
#endif
What am I missing here?
I tried to edit it to:
/**** QuatTypes.h - Basic type declarations ****/
#ifndef _H_QuatTypes
#define _H_QuatTypes
/*** Definitions ***/
struct Quat {float x, y, z, w;}; /* Quaternion */
enum QuatPart {X, Y, Z, W};
typedef float HMatrix[4][4]; /* Right-handed, for column vectors */
#define EulerAngles Quat ; /* (x,y,z)=ang 1,2,3, w=order code */
#endif
But it caused more errors.
If it is a .c file, it is compiled as C by default.
You either have to change the “compile as” option for that file, or add
extern "C"to the declaration in the .h file.