3.3 Where is Foundation.lib ?

Hello,

I’m new to Physx (and also to this forum) and i’d like to use SPH with physx. I’m having trouble creating the PxFoundation :

#include <extensions/PxDefaultErrorCallback.h>
#include <extensions/PxDefaultAllocator.h> 
#include <foundation/PxFoundation.h> 
#include <PxPhysicsAPI.h>

#include <iostream>

using namespace physx;

#pragma comment(lib, "PhysX3_x64.lib")
#pragma comment(lib, "Foundation.lib")
#pragma comment(lib, "PhysX3Extensions.lib")
#pragma comment(lib, "PhysX3Cooking_x64.lib")
#pragma comment(lib, "PxTask.lib")

int main(int argc, char *argv[])
{
	bool recordMemoryAllocations = true;
	PxDefaultErrorCallback gDefaultErrorCallback;
	PxDefaultAllocator gDefaultAllocatorCallback;

	PxFoundation *mFoundation = PxCreateFoundation(PX_PHYSICS_VERSION, gDefaultAllocatorCallback, gDefaultErrorCallback);
	
	if(!mFoundation)
		std::cout<<"PxCreateFoundation failed!"<<std::endl;


	return 0;
}

Compilation seems to work fine, but at the execution here is what i get :

1>------ Début de la génération : Projet : physxFluid, Configuration : Debug Win32 ------
1>main.obj : error LNK2019: symbole externe non résolu "public: __thiscall physx::PxDefaultErrorCallback::PxDefaultErrorCallback(void)" (??0PxDefaultErrorCallback@physx@@QAE@XZ) référencé dans la fonction _main
1>main.obj : error LNK2019: symbole externe non résolu "public: virtual __thiscall physx::PxDefaultErrorCallback::~PxDefaultErrorCallback(void)" (??1PxDefaultErrorCallback@physx@@UAE@XZ) référencé dans la fonction _main
1>main.obj : error LNK2019: symbole externe non résolu __imp__PxCreateFoundation référencé dans la fonction _main
1>G:\projects\physxFluid\Debug\physxFluid.exe : fatal error LNK1120: 3 externes non résolus
========== Génération : 0 a réussi, 1 a échoué, 0 mis à jour, 0 a été ignoré ==========

I don’t have any Foundation.lib in my physx installation. Any idea ? (i’m using visual studio 2012 professional)

Thanks !

Muska17

Include in your project properties -> Linker-> Input-> Additional dependencies:
PhysX3Extensions.lib

Doing so should not give you that linker error.

Greetings.

Thanks for your answer. I thought the pragma comment directives would do the job.

However i still have a problem. At the compilation :

fatal error C1189: #error :  Exactly one of NDEBUG and _DEBUG needs to be defined by preprocessor

I also tried to compile the same code with gcc on linux, and i have the same message ! :(

Here is my Makefile :

COMPILER=g++
OPTIONS=-std=gnu++0x
LIBS=./Lib/linux64/
HEADERS=./Include/
SRC=*.cpp
LINKS=-lPhysX3CharacterKinematic_x64 -lPhysX3Common_x64 -lPhysX3Cooking_x64 -lPhysX3Extensions -lPhysX3Vehicle -lPhysX3_x64 -lPhysXProfileSDK -lPhysXVisualDebuggerSDK -lPxTask

all:
	$(COMPILER) $(OPTIONS) -I$(HEADERS) -L$(LIBS) $(SRC)
clean:
	rm -f *.out *.o *~

My code :

#include <extensions/PxDefaultErrorCallback.h>
#include <extensions/PxDefaultAllocator.h>
#include <foundation/PxFoundation.h>
#include <PxPhysicsAPI.h>

#include <iostream>

using namespace physx;

int main(int argc, char *argv[])
{
	bool recordMemoryAllocations = true;
	PxDefaultErrorCallback gDefaultErrorCallback;
	PxDefaultAllocator gDefaultAllocatorCallback;

	PxFoundation *mFoundation = PxCreateFoundation(PX_PHYSICS_VERSION, gDefaultAllocatorCallback, gDefaultErrorCallback);
	
	if(!mFoundation)
			std::cout<<"PxCreateFoundation failed!"<<std::endl;

	return 0;
}

And the tree of my project :

Include
  vehicle
  particles
  ...
Lib
  linux32
  linux64
main.cpp
Makefile

Solved adding :

OPTIONS=-std=gnu++0x -DNDEBUG

pthread required on linux :

LINKS= [...] -lpthread