3.3 Linking errors

Hello,

I’m trying to build and run this code using the following Makefile but i have all the following linking errors (ubuntu 12.04, gcc 4.6.3). I’m linking all the physx .a files in the same order provided in the snippets, and using the same building options. I also link the same libraries as you can see.

I can build and run this as long as the PxPhysics stuff is commented.

#include <PxPhysicsAPI.h>
 
#include <iostream>
 
using namespace physx;
using namespace std;
 
int main(int argc, char *argv[])
{
    cout<<"Début physx"<<endl;

    PxDefaultErrorCallback gDefaultErrorCallback;
    PxDefaultAllocator gDefaultAllocatorCallback;
  
    /*
     * On crée le singleton fondation
     */
    PxFoundation *mFoundation = PxCreateFoundation(PX_PHYSICS_VERSION, gDefaultAllocatorCallback, gDefaultErrorCallback);
    if(!mFoundation)
            cout<<"PxCreateFoundation failed!"<<endl;
    
    /*
     * Pour le profiler de performance avec le visual debugger
     */
    PxProfileZoneManager *mProfileZoneManager = &PxProfileZoneManager::createProfileZoneManager(mFoundation);
    if(!mProfileZoneManager)
         cout<<"PxProfileZoneManager::createProfileZoneManager failed!"<<endl;  
    
    /*
     * PxToleranceScale
     */
    PxTolerancesScale *pxToleranceScale = new PxTolerancesScale();
    
    /*
     * On crée l'univers PxPhysics
     */
    PxPhysics *mPhysics = PxCreatePhysics(PX_PHYSICS_VERSION, *mFoundation,
                                *pxToleranceScale, true, mProfileZoneManager );
    if(!mPhysics)
        cout<<"PxCreatePhysics failed!"<<endl;
    
    cout<<"Fin physx"<<endl;
    return 0;
}
COMPILER=g++
OPTIONS=-std=gnu++0x -DNDEBUG
SRC= *.cpp

INCLUDE= ./Include
LDIR=./Lib/linux64

LIBS=-lPvdRuntime
LIBS+=-lSimulationController
LIBS+=-lSceneQuery
LIBS+=-lLowLevel
LIBS+=-lLowLevelCloth
LIBS+=-lPhysX3 
LIBS+=-lPhysX3Vehicle
LIBS+=-lPhysX3Cooking
LIBS+=-lPhysX3Extensions
LIBS+=-lPhysX3CharacterKinematic
LIBS+=-lPhysXProfileSDK 
LIBS+=-lPhysXVisualDebuggerSDK
LIBS+=-lPxTask
LIBS+=-lPhysX3Common
LIBS+=-lGL
LIBS+=-lGLU
LIBS+=-lglut
LIBS+=-lX11
LIBS+=-lrt
LIBS+=-lpthread

EXTRAS=-MMD
EXTRAS+=-Werror -m64 -fPIC -msse2 -mfpmath=sse -ffast-math -fno-exceptions -fno-rtti -Wno-invalid-offsetof -Wno-unknown-pragmas
EXTRAS+=-O3 -fno-strict-aliasing
EXTRAS+=-m64

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

linking errors here : http://pastebin.com/6tVgYwFJ

Any help would be really kind !

Mathias

Try the order I posted here
https://devtalk.nvidia.com/default/topic/724210/physx-and-physics-modeling/several-tipps-for-compiling-on-linux/

Have fun

Thanks for your anwser.

I just tried to link in that order but it does not change anything, i still get as much linking errors as before .

I also read somewhere we could link the libraries twice so the order does not matte. I tried this :

COMPILER=g++
OPTIONS=-std=gnu++0x -DNDEBUG
SRC= *.cpp

INCLUDE= ./Include
LDIR=./Lib/linux64

#LowLevel LowLevelCloth SceneQuery SimulationController PhysX3 PhysX3Common PhysX3Cooking PhysX3Extensions PhysXProfileSDK PxTask

LIBS=-lLowLevel
LIBS+=-lLowLevelCloth
LIBS+=-lSceneQuery
LIBS+=-lSimulationController
LIBS+=-lPvdRuntime
LIBS+=-lPhysX3Cooking
LIBS+=-lPxTask
LIBS+=-lPhysX3Vehicle
LIBS+=-lPhysX3CharacterKinematic
LIBS+=-lPhysXVisualDebuggerSDK
LIBS+=-lPhysXProfileSDK
LIBS+=-lPhysX3Extensions
LIBS+=-lPhysX3Common
LIBS+=-lPhysX3

LIBS+=-lLowLevel
LIBS+=-lLowLevelCloth
LIBS+=-lSceneQuery
LIBS+=-lSimulationController
LIBS+=-lPvdRuntime
LIBS+=-lPhysX3Cooking
LIBS+=-lPxTask
LIBS+=-lPhysX3Vehicle
LIBS+=-lPhysX3CharacterKinematic
LIBS+=-lPhysXVisualDebuggerSDK
LIBS+=-lPhysXProfileSDK
LIBS+=-lPhysX3Extensions
LIBS+=-lPhysX3Common
LIBS+=-lPhysX3

LIBS+=-lGL
LIBS+=-lGLU
LIBS+=-lglut
LIBS+=-lX11
LIBS+=-lrt
LIBS+=-lpthread

EXTRAS=-m64  -ffast-math

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

I have far less errors but still :

g++  -std=gnu++0x -DNDEBUG -m64  -ffast-math -I./Include -L./Lib/linux64 *.cpp -lLowLevel -lLowLevelCloth -lSceneQuery -lSimulationController -lPvdRuntime -lPhysX3Cooking -lPxTask -lPhysX3Vehicle -lPhysX3CharacterKinematic -lPhysXVisualDebuggerSDK -lPhysXProfileSDK -lPhysX3Extensions -lPhysX3Common -lPhysX3 -lLowLevel -lLowLevelCloth -lSceneQuery -lSimulationController -lPvdRuntime -lPhysX3Cooking -lPxTask -lPhysX3Vehicle -lPhysX3CharacterKinematic -lPhysXVisualDebuggerSDK -lPhysXProfileSDK -lPhysX3Extensions -lPhysX3Common -lPhysX3 -lGL -lGLU -lglut -lX11 -lrt -lpthread
./Lib/linux64/libSimulationController.a(ScBodySim.cpp.o):function physx::Sc::BodySim::postBody2WorldChange(): error: undefined reference to 'physx::PxsRigidBody::updatePoseDependenciesV(physx::PxsContext&)'
./Lib/linux64/libSimulationController.a(ScPhysics.cpp.o):function physx::Sc::Physics::registerCloth(): error: undefined reference to 'physx::cloth::Factory::createFactory(physx::cloth::Factory::Platform, physx::PxCudaContextManager*)'
./Lib/linux64/libSimulationController.a(ScClothCore.cpp.o):function physx::Sc::ClothCore::setStretchConfig(physx::PxClothFabricPhaseType::Enum, physx::PxClothStretchConfig const&): error: undefined reference to 'physx::cloth::PhaseConfig::PhaseConfig(unsigned short)'
./Lib/linux64/libSimulationController.a(ScClothCore.cpp.o):function physx::Sc::ClothCore::getStretchConfig(physx::PxClothFabricPhaseType::Enum) const: error: undefined reference to 'physx::cloth::PhaseConfig::PhaseConfig(unsigned short)'
./Lib/linux64/libSimulationController.a(ScClothCore.cpp.o):function physx::Sc::ClothCore::initLowLevel(physx::PxTransform const&, physx::PxClothParticle const*): error: undefined reference to 'physx::cloth::PhaseConfig::PhaseConfig(unsigned short)'
collect2: ld a retourné 1 code d'état d'exécution
make: *** [all] Erreur 1

BUILD FAILED (exit value 2, total time: 853ms)

Edit: it works when linking a third time xD