Integrating PhysX 3.4.2 into a project on Linux

I successfully managed to integrate PhysX into my small engine project, which I primarily develop on windows. Now I decided to make the engine also work on Linux platforms. I managed to compile the project without PhysX but not matter what knobs I turn, It just don’t want to compile with PhysX enabled.

Here is the error message including the compile command and the compiler flags I am getting:

/usr/bin/g++ -o bin/x86_64/Debug/Game @"Game.txt" -L. -L../PhotonBox/vendor/freetype/lib -L../PhotonBox/vendor/glad/lib -L../PhotonBox/vendor/GLFW/lib -L../PhotonBox/vendor/imgui/lib -L../PhotonBox/vendor/KHR/lib -L../PhotonBox/vendor/STB/lib -L../PhotonBox/vendor/zlib/lib -L../PhotonBox/vendor/PhysX/lib/debug -L../PhotonBox/vendor/PhysX/bin/debug   -m64 ../PhotonBox/bin/x86_64/Debug/libPhotonBox.a -lglfw3 -lzlib -lfreetype -lGL -lGLU -lX11 -lpng -lXxf86vm -lXrandr -lXinerama -lXcursor -lpthread -lXi -ldl -lPhysX3DEBUG_x64 -lPhysX3CommonDEBUG_x64 -lPxFoundationDEBUG_x64 -lPhysX3ExtensionsDEBUG
/usr/bin/ld: ../PhotonBox/vendor/PhysX/bin/debug/ undefined reference to symbol '_ZN5physx28PxTransformFromPlaneEquationERKNS_7PxPlaneE'
../PhotonBox/vendor/PhysX/bin/debug/ error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

I looked up PxTransformFromPlaneEquation which seems to be defined in the PxFoundation, which I am including. I also tried including them in a different order, but that just spits out different errors.

PS: Since PhysX does not generate .a files (for example PhysX3_x64.a), I just plug the .so files as if they were static. I am not sure if this is the way to do it but it somehow seems to almost work.

Would really appreciate if anyone could hint me into the right direction.
Here is the repo if needed:

linker on linux is sensitive to the order, you might need to figure out the correct order that works for you. If you want to link against PhysX static libs, you might want to consider upgrading to 4.1 (probably not that much work), where this is possible. There is also a correct linking order in the snippets shown, but thats for static libs.

Hi Ales

Thanks for the reply. I was indeed able to finally resolve the issue, by reordering the inclusion order of the dynamic PhysX libraries. In particular, I had to reverse the order. To document this for others, here is how my final ordering looked like:

  1. -lPxPvdSDK_x64
  2. -lPhysX3Extensions
  3. -lPxFoundation_x64
  4. -lPhysX3Common_x64
  5. -lPhysX3_x64

Additionally to the ordering issue, I had also problems running the compiled binaries. I had to manually patch the .so files to assign the rpath by calling

patchelf --set-rpath '.' *.so

This creates some other issues, while inside an IDE, but at least it is somewhat working.

Thanks again for the help!