Inna twórczość > C, C++
[C++] Błąd LNK2019 podczas przerabiania kodu
Drock:
Cześć,
Od kilku dni przerabiam kodu żeby wyodrębnić z niego klasy, i męczę się ostatnio z błędem LNK 2019....
Wcześniej go nie spotkałem :( ktoś wie jak go naprawić? Używam visual studio 2017
--- Kod: ---1>FApplication.obj : error LNK2019: unresolved external symbol "public: void __cdecl FCamera::Initialize(int,int,struct DirectX::__vector4,struct DirectX::__vector4,struct DirectX::__vector4)" (?Initialize@FCamera@@QEAAXHHU__vector4@DirectX@@00@Z) referenced in function "private: bool __cdecl FApplication::InitScene(void)" (?InitScene@FApplication@@AEAA_NXZ)
1>FApplication.obj : error LNK2019: unresolved external symbol "public: void __cdecl FCamera::UpdateCamera(struct DirectX::__vector4)" (?UpdateCamera@FCamera@@QEAAXU__vector4@DirectX@@@Z) referenced in function "private: void __cdecl FApplication::DetectInput(double)" (?DetectInput@FApplication@@AEAAXN@Z)
1>FApplication.obj : error LNK2019: unresolved external symbol "public: void __cdecl FCamera::SetParameters(float,float,struct DirectX::__vector4,struct DirectX::__vector4)" (?SetParameters@FCamera@@QEAAXMMU__vector4@DirectX@@0@Z) referenced in function "private: void __cdecl FApplication::DetectInput(double)" (?DetectInput@FApplication@@AEAAXN@Z)
1>FApplication.obj : error LNK2019: unresolved external symbol "public: struct DirectX::__vector4 __cdecl FCamera::GetPosition(void)" (?GetPosition@FCamera@@QEAA?AU__vector4@DirectX@@XZ) referenced in function "private: void __cdecl FApplication::UpdateScene(double)" (?UpdateScene@FApplication@@AEAAXN@Z)
1>FApplication.obj : error LNK2019: unresolved external symbol "public: struct DirectX::__vector4 __cdecl FCamera::GetRight(void)" (?GetRight@FCamera@@QEAA?AU__vector4@DirectX@@XZ) referenced in function "private: void __cdecl FApplication::DetectInput(double)" (?DetectInput@FApplication@@AEAAXN@Z)
1>FApplication.obj : error LNK2019: unresolved external symbol "public: struct DirectX::__vector4 __cdecl FCamera::GetForward(void)" (?GetForward@FCamera@@QEAA?AU__vector4@DirectX@@XZ) referenced in function "private: void __cdecl FApplication::DetectInput(double)" (?DetectInput@FApplication@@AEAAXN@Z)
1>C:\Users\batzi\source\repos\FEngine\x64\Debug\FEngine.exe : fatal error LNK1120: 6 unresolved externals
--- Koniec kodu ---
Kod klasy:
--- Kod: ---#pragma once
#include <DirectXMath.h>
using namespace DirectX;
class FCamera
{
public:
FCamera();
~FCamera();
void Initialize(int, int, XMVECTOR, XMVECTOR, XMVECTOR);
void UpdateCamera(XMVECTOR);
void SetParameters(float, float, XMVECTOR, XMVECTOR);
XMVECTOR GetPosition();
XMVECTOR GetRight();
XMVECTOR GetForward();
const XMMATRIX GetView();
const XMMATRIX GetProjection();
float GetYaw();
float GetPitch();
private:
const float mCharCamDist = 15.0f; //Distance between character and camera.
float mYaw;
float mPitch;
//Matrices.
XMMATRIX mView;
XMMATRIX mProjection;
XMMATRIX mRotationMatrix;
//Vectors.
XMVECTOR mPosition;
XMVECTOR mTarget;
XMVECTOR mUp;
XMVECTOR mForward;
XMVECTOR mRight;
XMVECTOR mDefaultForward;
XMVECTOR mDefaultRight;
};
--- Koniec kodu ---
wszystkie funkcje mam zdefiniowane w innym pliku
neko:
Błąd linkera, podeślij plik z implementacją tej klasy.
Wonski:
Jak kolega wyżej napisał..
gdzieś nie masz zalinkowanej libki
neko:
Ewentualnie jak tworzysz gdzieś obiekty tej klasy to podeślij też fragment kodu w którym wywołujesz konstruktor.
Drock:
To jest definicja tej klasy
--- Kod: ---#include "FCamera.h"
FCamera::FCamera()
{
mYaw = 0.0f;
mPitch = 0.0f;
mDefaultForward = XMVectorSet(0.0f, 0.0f, 1.0f, 0.0f);
mDefaultRight = XMVectorSet(1.0f, 0.0f, 0.0f, 0.0f);
mForward = XMVectorSet(0.0f, 0.0f, 1.0f, 0.0f);
mRight = XMVectorSet(1.0f, 0.0f, 0.0f, 0.0f);
}
FCamera::~FCamera()
{
}
void FCamera::Initialize(int width, int height, XMVECTOR camPosition, XMVECTOR camTarget, XMVECTOR camUp)
{
mView = XMMatrixLookAtLH(mPosition, mTarget, mUp);
mProjection = XMMatrixPerspectiveFovLH(3.14f / 4.0f, (float)width / height, 1.0f, 200.0f);
}
void FCamera::UpdateCamera(XMVECTOR charPosition)
{
// Set the camera target at character.
mTarget = charPosition;
mTarget = XMVectorSetY(mTarget, XMVectorGetY(mTarget) + 5.0f);
// Rotate camera around target
mRotationMatrix = XMMatrixRotationRollPitchYaw(-mPitch, mYaw, 0);
mPosition = XMVector3TransformNormal(mDefaultForward, mRotationMatrix);
mPosition = XMVector3Normalize(mPosition);
// Set our cameras position to rotate around the character.
mPosition = (mPosition * mCharCamDist) + mTarget;
mForward = XMVector3Normalize(mTarget - mPosition);
mForward = XMVectorSetY(mForward, 0.0f);
mForward = XMVector3Normalize(mForward);
mRight = XMVectorSet(-XMVectorGetZ(mForward), 0.0f, XMVectorGetX(mForward), 0.0f);
mUp = XMVector3Normalize(XMVector3Cross(XMVector3Normalize(mPosition - mTarget), mRight));
mView = XMMatrixLookAtLH(mPosition, mTarget, mUp);
}
void FCamera::SetParameters(float camYaw, float camPitch, XMVECTOR camRight, XMVECTOR camForward)
{
mYaw = camYaw;
mPitch = camPitch;
mRight = camRight;
mForward = camForward;
}
XMVECTOR FCamera::GetPosition()
{
return mPosition;
}
XMVECTOR FCamera::GetRight()
{
return mRight;
}
XMVECTOR FCamera::GetForward()
{
return mForward;
}
const XMMATRIX FCamera::GetView()
{
return mView;
}
const XMMATRIX FCamera::GetProjection()
{
return mProjection;
}
float FCamera::GetYaw()
{
return mYaw;
}
float FCamera::GetPitch()
{
return mPitch;
}
--- Koniec kodu ---
Narazie nie mam dostępu do pliku w którym wywołuje podeślę jak wrócę do domu
Nawigacja
[#] Następna strona
Idź do wersji pełnej