Problem with PxDefaultErrorCallback (PhysX 3.4)

Hi everyone !

I have a problem when initializing physX (3.4). When I try to create an error callback (PxDefaultErrorCallback), I get this error :

LNK2019 unresolved external symbol “public: __thiscall physx::PxDefaultErrorCallback::PxDefaultErrorCallback(void)”

Here is my code :

PhysX.h :

#ifndef _PHYSX_
#define _PHYSX_

#include "Vec3.h"

#include "PxPhysicsAPI.h"
#include "PxDefaultAllocator.h"
#include "PxDefaultErrorCallback.h"

namespace physics
	class PhysX
		physx::PxPhysics* _sdk = NULL;
		physx::PxFoundation* _foundation = NULL;

		physx::PxScene* _scene;

		PhysX() = default;
		~PhysX() = default;

		bool Initialize();
		void Shutdown();


PhysX.cpp :

#include "PhysX.h"
#include <iostream>

using namespace physx;
using namespace physics;

bool PhysX::Initialize()
	static PxDefaultErrorCallback errorCallback; // the error appears because of this line
	static PxDefaultAllocator allocatorCallback;

	_foundation = PxCreateFoundation(PX_FOUNDATION_VERSION, allocatorCallback, errorCallback);
	if (!_foundation)
		return false;

	return true;

void PhysX::Shutdown(){}

I linked the minimum libraries needed (PhysX3DEBUG_x86.lib, PhysX3CommonDEBUG_x86.lib and PxFoundationDEBUG_x86.lib, I try to compile in Debug x86 for the moment). Maybe I forgot to link a library ?

I also read that I was supposed to implement the virtual function reportError in PxDefaultErrorCallback, but I just got more errors :


#include "foundation/PxErrorCallback.h"
#include "PxPhysXConfig.h"

namespace physx

	\brief default implementation of the error callback

	This class is provided in order to enable the SDK to be started with the minimum of user code. Typically an application
	will use its own error callback, and log the error to file or otherwise make it visible. Warnings and error messages from
	the SDK are usually indicative that changes are required in order for PhysX to function correctly, and should not be ignored.

	class PxDefaultErrorCallback : public PxErrorCallback

		virtual void reportError(PxErrorCode::Enum code, const char* message, const char* file, int line); // supposed to implement that function

// Code that I tried to add
/*void PxDefaultErrorCallback::reportError(PxErrorCode::Enum code, const char* message, const char* file, int line)

} // namespace physx


Any idea ? I don’t really see where this error could come from…

you need to link also the extensions library, if you use the PxDefaultErrorCallback. The implementation is in this library.
So try to add a PhysX3ExtensionsDEBUG.lib to your project.


Thanks, it was that ! The weird thing is that compiling PhysX.sln didn’t build PhysX3Extensions.lib and a few other libraries, so I had to modify the build settings, something like that…

Thanks !