我一直在VS2010的directX和C++中使用xnacollision,我一直收到这个错误。
Error 1 error LNK2019: unresolved external symbol "int __cdecl XNA::IntersectSphereSphere(struct XNA::Sphere const *,struct XNA::Sphere const *)" (?IntersectSphereSphere@XNA@@YAHPBUSphere@1@0@Z) referenced in function "public: virtual void __thiscall PhysicsApp::UpdateScene(float)" (?UpdateScene@PhysicsApp@@UAEXM@Z) C:\Users\Andrew\Desktop\Physics 20 Percent Project\PhysicsDemo.obj PhysicsDemo当我这样做的时候
XNA::Sphere sphere1, sphere2;
sphere1.Radius = 1.0f;
sphere1.Center = XMFLOAT3(0.0f, 0.0f, 0.0f);
sphere2.Radius = 1.0f;
sphere2.Radius = XMFLOAT3(2.0f, 0.0f, 0.0f);
int collision = XNA::IntersectSphereSphere(&sphere1, &sphere2);我已经包含了xnacollision.h。
发布于 2014-04-16 02:54:14
#include头文件并不是让这些东西正常工作所需要做的唯一的事情。您还必须链接到适当的.lib文件,这正是链接器所抱怨的。您需要检查您的链接器设置,并确保您的搜索路径是正确的,并且必要的外部依赖项已得到处理。
发布于 2014-12-02 05:06:34
XNACollision不仅仅是一个头文件。它既是一个头文件,也是一个cpp文件,作为Direct3D 9冲突示例的一部分在遗留的DirectX开发工具包中提供。它不是遗留的D3DX11库的一部分。
在Windows8.xSDK中,DirectXMath将XNACollision.h/.cpp中的冲突类型作为DirectXCollision.h包含在标准的include头中(它都是内联的,所以没有.cpp文件或.lib)。有一个使用它的Collision示例的更新版本。
参见Introducing DirectXMath。
因为您使用的是D3DX11和XNAMath,所以很明显您使用的是遗留的DirectX SDK。请注意,这两种方法都已弃用。参见MSDN和Living without D3DX。
https://stackoverflow.com/questions/23092001
复制相似问题