I’ve downloaded this : PhysX-3.3.0_PC_SDK_Core.
And I want to run a test code here:
#include <stdio.h>
#include <iostream>
#include <vector>
#include <GL/glut.h>
#include <PxPhysicsAPI.h>
#include <extensions/PxExtensionsAPI.h>
#include <extensions/PxDefaultErrorCallback.h>
#include <extensions/PxDefaultAllocator.h>
#include <extensions/PxDefaultSimulationFilterShader.h>
#include <extensions/PxDefaultCpuDispatcher.h>
#include <extensions/PxShapeExt.h>
#include <extensions/PxSimpleFactory.h>
#include <PxSimulationEventCallback.h>
#include <foundation/PxFoundation.h>
#pragma comment(lib, "PhysX3_x64.lib")
#pragma comment(lib, "PhysX3Common_x64.lib")
#pragma comment(lib, "PhysX3Extensions.lib")
#pragma comment(lib, "PxTask.lib")
//PhysX3_x64.lib;PhysX3Common_x64.lib;PhysX3Extensions.lib;PxTask.lib;
using namespace physx;
using namespace std;
static PxPhysics* gPhysicsSDK = NULL;
static PxDefaultErrorCallback gDefaultErrorCallback;
static PxDefaultAllocator gDefaultAllocatorCallback;
static PxSimulationFilterShader gDefaultFilterShader=PxDefaultSimulationFilterShader;
int startTime = 0, totalFrames = 0;
float fps = 0;
const int WINDOW_WIDTH = 800, WINDOW_HEIGHT = 600;
PxScene* gScene = NULL;
PxReal myTimestep = 1.0f/60.0f;
void StepPhysX()
{
gScene->simulate(myTimestep);
while(!gScene->fetchResults() )
{
// do something useful
}
}
void InitializePhysX()
{
PxFoundation* foundation = PxCreateFoundation(PX_PHYSICS_VERSION, gDefaultAllocatorCallback, gDefaultErrorCallback);
gPhysicsSDK = PxCreatePhysics(PX_PHYSICS_VERSION, *foundation, PxTolerancesScale() );
PxInitExtensions(*gPhysicsSDK);
// Create the scene
PxSceneDesc sceneDesc(gPhysicsSDK->getTolerancesScale());
sceneDesc.gravity = PxVec3(0.0f, -9.8f, 0.0f);
if(!sceneDesc.cpuDispatcher)
{
PxDefaultCpuDispatcher* mCpuDispatcher = PxDefaultCpuDispatcherCreate(1);
sceneDesc.cpuDispatcher = mCpuDispatcher;
}
if(!sceneDesc.filterShader)
sceneDesc.filterShader = gDefaultFilterShader;
gScene = gPhysicsSDK->createScene(sceneDesc);
}
void ShutdownPhysX()
{
gScene->release();
gPhysicsSDK->release();
}
void OnShutdown()
{
ShutdownPhysX();
}
void OnRender()
{
totalFrames++;
int current = glutGet(GLUT_ELAPSED_TIME);
if((current-startTime)>1000)
{
float elapsedTime = float(current-startTime);
fps = ((totalFrames * 1000.0f)/ elapsedTime);
startTime = current;
totalFrames = 0;
}
if (gScene)
StepPhysX();
glClearColor(0.1, 0.1, 0.1, 1.0);
glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glutSwapBuffers();
}
void OnIdle()
{
glutPostRedisplay();
}
void main(int argc, char** argv)
{
atexit(OnShutdown);
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
glutInitWindowSize(WINDOW_WIDTH, WINDOW_HEIGHT);
glutCreateWindow("Initialization");
glutDisplayFunc(OnRender);
glutIdleFunc(OnIdle);
InitializePhysX();
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);
glutMainLoop();
}
But errors show up:
>main.obj : error LNK2001: 无法解析的外部符号 "class physx::PxFlags<enum physx::PxFilterFlag::Enum,unsigned short> __cdecl physx::PxDefaultSimulationFilterShader(unsigned int,struct physx::PxFilterData,unsigned int,struct physx::PxFilterData,class physx::PxFlags<enum physx::PxPairFlag::Enum,unsigned short> &,void const *,unsigned int)" (?PxDefaultSimulationFilterShader@physx@@YA?AV?$PxFlags@W4Enum@PxFilterFlag@physx@@G@1@IUPxFilterData@1@I0AAV?$PxFlags@W4Enum@PxPairFlag@physx@@G@1@PBXI@Z)
1>main.obj : error LNK2019: 无法解析的外部符号 "class physx::PxDefaultCpuDispatcher * __cdecl physx::PxDefaultCpuDispatcherCreate(unsigned int,unsigned int *)" (?PxDefaultCpuDispatcherCreate@physx@@YAPAVPxDefaultCpuDispatcher@1@IPAI@Z),该符号在函数 "void __cdecl InitializePhysX(void)" (?InitializePhysX@@YAXXZ) 中被引用
1>main.obj : error LNK2019: 无法解析的外部符号 _PxInitExtensions,该符号在函数 "void __cdecl InitializePhysX(void)" (?InitializePhysX@@YAXXZ) 中被引用
1>main.obj : error LNK2019: 无法解析的外部符号 __imp__PxCreateFoundation,该符号在函数 "void __cdecl InitializePhysX(void)" (?InitializePhysX@@YAXXZ) 中被引用
1>main.obj : error LNK2019: 无法解析的外部符号 __imp__PxRegisterParticles,该符号在函数 "class physx::PxPhysics * __cdecl PxCreatePhysics(unsigned int,class physx::PxFoundation &,class physx::PxTolerancesScale const &,bool,class physx::PxProfileZoneManager *)" (?PxCreatePhysics@@YAPAVPxPhysics@physx@@IAAVPxFoundation@2@ABVPxTolerancesScale@2@_NPAVPxProfileZoneManager@2@@Z) 中被引用
1>main.obj : error LNK2019: 无法解析的外部符号 __imp__PxRegisterCloth,该符号在函数 "class physx::PxPhysics * __cdecl PxCreatePhysics(unsigned int,class physx::PxFoundation &,class physx::PxTolerancesScale const &,bool,class physx::PxProfileZoneManager *)" (?PxCreatePhysics@@YAPAVPxPhysics@physx@@IAAVPxFoundation@2@ABVPxTolerancesScale@2@_NPAVPxProfileZoneManager@2@@Z) 中被引用
1>main.obj : error LNK2019: 无法解析的外部符号 __imp__PxRegisterHeightFields,该符号在函数 "class physx::PxPhysics * __cdecl PxCreatePhysics(unsigned int,class physx::PxFoundation &,class physx::PxTolerancesScale const &,bool,class physx::PxProfileZoneManager *)" (?PxCreatePhysics@@YAPAVPxPhysics@physx@@IAAVPxFoundation@2@ABVPxTolerancesScale@2@_NPAVPxProfileZoneManager@2@@Z) 中被引用
1>main.obj : error LNK2019: 无法解析的外部符号 __imp__PxRegisterArticulations,该符号在函数 "class physx::PxPhysics * __cdecl PxCreatePhysics(unsigned int,class physx::PxFoundation &,class physx::PxTolerancesScale const &,bool,class physx::PxProfileZoneManager *)" (?PxCreatePhysics@@YAPAVPxPhysics@physx@@IAAVPxFoundation@2@ABVPxTolerancesScale@2@_NPAVPxProfileZoneManager@2@@Z) 中被引用
1>main.obj : error LNK2019: 无法解析的外部符号 __imp__PxCreateBasePhysics,该符号在函数 "class physx::PxPhysics * __cdecl PxCreatePhysics(unsigned int,class physx::PxFoundation &,class physx::PxTolerancesScale const &,bool,class physx::PxProfileZoneManager *)" (?PxCreatePhysics@@YAPAVPxPhysics@physx@@IAAVPxFoundation@2@ABVPxTolerancesScale@2@_NPAVPxProfileZoneManager@2@@Z) 中被引用
1>main.obj : error LNK2019: 无法解析的外部符号 "public: __thiscall physx::PxDefaultErrorCallback::PxDefaultErrorCallback(void)" (??0PxDefaultErrorCallback@physx@@QAE@XZ),该符号在函数 "void __cdecl `dynamic initializer for 'gDefaultErrorCallback''(void)" (??__EgDefaultErrorCallback@@YAXXZ) 中被引用
1>main.obj : error LNK2019: 无法解析的外部符号 "public: virtual __thiscall physx::PxDefaultErrorCallback::~PxDefaultErrorCallback(void)" (??1PxDefaultErrorCallback@physx@@UAE@XZ),该符号在函数 "void __cdecl `dynamic atexit destructor for 'gDefaultErrorCallback''(void)" (??__FgDefaultErrorCallback@@YAXXZ) 中被引用
1>H:\重要项目\asus\Documents\Visual Studio 2010\PhsyxTest\Debug\PhsyxTest.exe : fatal error LNK1120: 11 个无法解析的外部命令
And I set the directories like this:
External Media
But I make it a little difference : “win32” here is replaced by “win64”
please help me, thanks in advance!