Compiling PhysX libs for Android

Dear everyone,

We are trying to compile the PhysX libraries for mobile platforms, to achieve runtime physics cooking (we know it’s not recommended due to performance). So what we did is we cloned the source of the engine, and according to Master Kenth’s original idea we modified parts to include the PhysX libraries in the cooking proccess. Namely we did the following changes:

\ThirdParty\PhysX\PhysX.Build.cs: Under string[] StaticLibrariesAndroid = new string[] { we changed:

//"PhysX3Cooking{0}", to

"PhysX3Cooking{0}",

in UnrealBuildTool\Android\UEBuildAndroid.cs we changed:

UEBuildConfiguration.bRuntimePhysicsCooking = false; to

UEBuildConfiguration.bRuntimePhysicsCooking = true;

and for our project build.cs we added the following:

public override void SetupGlobalEnvironment(
	TargetInfo Target,
	ref LinkEnvironmentConfiguration OutLinkEnvironmentConfiguration,
	ref CPPEnvironmentConfiguration OutCPPEnvironmentConfiguration
	)
	{
		UEBuildConfiguration.bCompilePhysX = true;
		UEBuildConfiguration.bRuntimePhysicsCooking = true;

		OutCPPEnvironmentConfiguration.Definitions.Add("WITH_RUNTIME_PHYSICS_COOKING=1");
        
	}

We compiled the engine. All went well, no issues at all. So we loaded our solution of the test project itself, added the nodes which caused problems before, and started to build. It looked like all goes well, however at the end of the build proccess we get this error:

3>  [280/280] clang++.exe MobileTest-Android-DebugGame-armv7-es2.so
3>C:/NVPACK/android-ndk-r12b/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin\ld : error : cannot find -lPhysX3CookingPROFILE
3>  D:\SOURCES\UnrealEngine4\UnrealEngine\Engine\Source\Runtime\Engine\Private\PhysicsEngine/PhysLevel.cpp:330: error: undefined reference to 'PxCreateCooking(unsigned int, physx::PxFoundation&, physx::PxCookingParams const&)'
3>clang++.exe : error : linker command failed with exit code 1 (use -v to see invocation)
3>ERROR : UBT error : Failed to produce item: C:\Users\lostr\Documents\Unreal Projects\MobileTest\Binaries\Android\MobileTest-Android-DebugGame-armv7-es2.so
3>  Total build time: 1220,65 seconds
3>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.MakeFile.targets(41,5): error MSB3075: The command "D:\SOURCES\UnrealEngine4\UnrealEngine\Engine\Build\BatchFiles\Build.bat MobileTest Android DebugGame "C:\Users\lostr\Documents\Unreal Projects\MobileTest\MobileTest.uproject" -waitmutex" exited with code 5. Please verify that you have sufficient rights to run this command.
========== Build: 0 succeeded, 2 failed, 1 up-to-date, 1 skipped ==========

We are having a hard time doing minor changes and recompiling everything because of hardware limitations, the build times can be horribly long. Do anyone has an idea what to do and where exactly? We are suspecting that the problem is Nvidia related with the correct profiles not being included in their NVPACK. “arm-linux-androideabi/bin\ld : error : cannot find -lPhysX3CookingPROFILE” is the part which suggests this.

Thank you everyone in advance!

Hey Lostra,

To clarify, the engine builds fine, but the issue arises when you attempt to package the project for Android? If this is the case, what is your exact build configuration for your Android packaging?

Does the same happen if you attempt to package for Windows?

Thanks

Hello Sean!

Yes, the engine builds fine, Windows packaging works fine, the problem happens anytime we want to package for Android/iOS. We are trying to build with the default Development settings.

Hey Lostra,

Sorry for the delay.

After further discussion, this is not something that we allow the cooker to do currently. The only use for it at the moment is for Apex destructible meshes, and that’s not something we support on mobile.

You’re welcome to put in a github pull request for it, but otherwise there are no plans to change this at this time, as the developers are currently focusing their efforts on high-priority crashes and blockers.

Have a great day

hello sir
i have same problem even with stock settings.
i downloaded 4.16.3 source yesterday and compiling of engine was scsful bt every time i try to build the project it fails with errors i dont have any idea
for eg
UnrealBuildTool: C:\UnrealEngine-4.16\Engine\Plugins\Runtime\PhysXVehicles\Source\PhysXVehicles\Private/WheeledVehicleMovementComponent4W.cpp:260: error: undefined reference to 'physx::PxVehicleDrive4W::setup(physx::PxPhysics*, physx::PxRigidDynamic*, physx::PxVehicleWheelsSimData const&, physx::PxVehicleDriveSimData4W
UATHelper: Packaging (Android (ETC1)): UnrealBuildTool: C:\UnrealEngine-4.16\Engine\Plugins\Runtime\PhysXVehicles\Source\PhysXVehicles\Private/WheeledVehicleMovementComponent4W.cpp:261: error: undefined reference to ‘physx::PxVehicleDrive4W::setToRestState()’

.cpp:426: error: undefined reference to ‘physx::PxVehicleWheelsSimData::setMinLongSlipDenominator(float)’

undefined reference to 'physx::immediate::PxGenerateContacts(physx::PxGeometry const* const*, physx::PxGeometry const* const*, physx::PxTransform const*, physx::PxTrans

i dont have any idea what to do.
please help me…