Sign in to follow this  

global funtions

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

i have made some funtions and would like to access them from any of my cpp files and classes in my program ,

but i am not sure how to do this.

declare them in a global.h and define them in a global.cpp , i tryed this but i got
an error

error LNK2019: unresolved external symbol "void __cdecl GetfacingVector(class tle::IModel *,struct D3DXVECTOR3 &)

in the cpp file its defined as
void GetfacingVector( IModel *model, D3DXVECTOR3 &dir)
{
// content
}

in classes you would say myclass::GetfacingVector( IModel *model, D3DXVECTOR3 &dir)

but i want to just be able to access it via code GetfacingVector

can you tell me what i am doing wrong plaease

Share this post


Link to post
Share on other sites
Make sure you're spelling the function right the second time. Also make sure you're not defining something in a class then not putting the class marker on it. Example, defining a function as

void MyClass::MyFunction();

Then actually programming it as just void MyFunction();

Share this post


Link to post
Share on other sites
global.h


void GetParallelVector( IModel *model, D3DXVECTOR3 &dir);
void GetfacingVector( IModel *model, D3DXVECTOR3 &dir);
void GetPosVect(IModel *pModel,D3DXVECTOR3 &dir);



global.cpp


#include "global.h"



void GetfacingVector( IModel *model, D3DXVECTOR3 &dir)
{
float matrix[16];

model->GetMatrix( matrix );
dir.x = matrix[8];
dir.y = matrix[9];
dir.z = matrix[10];
}

void GetParallelVector( IModel *model, D3DXVECTOR3 &dir)
{
float matrix[16];

model->GetMatrix( matrix );
dir.x = matrix[0];
dir.y = matrix[1];
dir.z = matrix[2];
}



void GetPosVect(IModel *pModel,D3DXVECTOR3 &dir)
{
dir.x = pModel->GetX();
dir.y = pModel->GetY();
dir.z = pModel->GetZ();
}

Share this post


Link to post
Share on other sites
Ensure you only have 1 global.cpp in the directories. The rule to make the file might select the wrong file if there are multiple copies in your folders.

a nice little check is place

#pragma message("can you read me")

If you see the message in you build log then you know its using the correct file.

Share this post


Link to post
Share on other sites
Do the global.h and global.cpp files have proper knowledge of the IModel class? I assume that's not the entire header file. Are they both namespaced properly as tle::IModel?

Why don't you post your entire global .h/.cpp inside source tag so we can look at it, assuming you haven't fixed the problem.

Share this post


Link to post
Share on other sites

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