Linking Bullet Physics with Unreal Engine 4

I’ve a good news! I was successful to build Bullet like a static library!

What I was missing is to add this Type = ModuleType.External; to Bullet.Build.cs

However to check if the engine is ready to use Bullet I wrote this function:



#include "btBulletDynamicsCommon.h"

void UWorld::CreatePhysicsScene()
{
        // Bullet Test
	btDefaultCollisionConfiguration* collisionConfiguration = new btDefaultCollisionConfiguration();
	delete collisionConfiguration;
	collisionConfiguration = nullptr;

	///collision configuration contains default setup for memory, collision setup. Advanced users can create their own configuration.
	SetPhysicsScene(new FPhysScene());
}

Where the building fail with error:


1>------ Build started: Project: ShaderCompileWorker, Configuration: Development_Program x64 ------
1>  Target is up to date
1>  Deploying ShaderCompileWorker Win64 Development...
1>  Total build time: 0.20 seconds (NoActionsToExecute executor: 0.00 seconds)
2>------ Build started: Project: UE4, Configuration: Development_Editor x64 ------
2>  Performing full C++ include scan (building a new target)
2>  Performing 3 actions (4 in parallel)
2>  World.cpp
2>d:\workspace\githubprojects\ue_4.16\unrealengine\engine\source	hirdparty\bullet\win64\include\bullet\LinearMath/btThreads.h(73): warning C4668: 'BT_THREADSAFE' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
2>d:\workspace\githubprojects\ue_4.16\unrealengine\engine\source	hirdparty\bullet\win64\include\bullet\LinearMath/btThreads.h(80): warning C4668: 'BT_THREADSAFE' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
2>d:\workspace\githubprojects\ue_4.16\unrealengine\engine\source	hirdparty\bullet\win64\include\bullet\LinearMath/btThreads.h(87): warning C4668: 'BT_THREADSAFE' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
2>  [2/3] Link UE4Editor-Engine.lib
2>  [3/3] Link UE4Editor-Engine.dll
2>     Creating library D:\WorkSpace\GitHubProjects\UE_4.16\UnrealEngine\Engine\Intermediate\Build\Win64\UE4Editor\Development\UE4Editor-Engine.lib and object D:\WorkSpace\GitHubProjects\UE_4.16\UnrealEngine\Engine\Intermediate\Build\Win64\UE4Editor\Development\UE4Editor-Engine.exp
2>BulletCollision_Debug.lib(btDefaultCollisionConfiguration.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in PCH.Engine.h.obj
2>BulletCollision_Debug.lib(btDefaultCollisionConfiguration.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MD_DynamicRelease' in PCH.Engine.h.obj
2>BulletCollision_Debug.lib(btConvexConvexAlgorithm.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in PCH.Engine.h.obj
2>BulletCollision_Debug.lib(btConvexConvexAlgorithm.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MD_DynamicRelease' in PCH.Engine.h.obj
2>BulletCollision_Debug.lib(btEmptyCollisionAlgorithm.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in PCH.Engine.h.obj
2>BulletCollision_Debug.lib(btEmptyCollisionAlgorithm.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MD_DynamicRelease' in PCH.Engine.h.obj
2>BulletCollision_Debug.lib(btConvexConcaveCollisionAlgorithm.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in PCH.Engine.h.obj
2>BulletCollision_Debug.lib(btConvexConcaveCollisionAlgorithm.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MD_DynamicRelease' in PCH.Engine.h.obj
2>BulletCollision_Debug.lib(btCompoundCollisionAlgorithm.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in PCH.Engine.h.obj
2>BulletCollision_Debug.lib(btCompoundCollisionAlgorithm.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MD_DynamicRelease' in PCH.Engine.h.obj
2>BulletCollision_Debug.lib(btCompoundCompoundCollisionAlgorithm.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in PCH.Engine.h.obj
2>BulletCollision_Debug.lib(btCompoundCompoundCollisionAlgorithm.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MD_DynamicRelease' in PCH.Engine.h.obj
2>BulletCollision_Debug.lib(btConvexPlaneCollisionAlgorithm.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in PCH.Engine.h.obj
2>BulletCollision_Debug.lib(btConvexPlaneCollisionAlgorithm.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MD_DynamicRelease' in PCH.Engine.h.obj
2>BulletCollision_Debug.lib(btBoxBoxCollisionAlgorithm.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in PCH.Engine.h.obj
2>BulletCollision_Debug.lib(btBoxBoxCollisionAlgorithm.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MD_DynamicRelease' in PCH.Engine.h.obj
2>BulletCollision_Debug.lib(btSphereSphereCollisionAlgorithm.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in PCH.Engine.h.obj
2>BulletCollision_Debug.lib(btSphereSphereCollisionAlgorithm.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MD_DynamicRelease' in PCH.Engine.h.obj
2>BulletCollision_Debug.lib(btSphereTriangleCollisionAlgorithm.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in PCH.Engine.h.obj
2>BulletCollision_Debug.lib(btSphereTriangleCollisionAlgorithm.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MD_DynamicRelease' in PCH.Engine.h.obj
2>BulletCollision_Debug.lib(btActivatingCollisionAlgorithm.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in PCH.Engine.h.obj
2>BulletCollision_Debug.lib(btActivatingCollisionAlgorithm.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MD_DynamicRelease' in PCH.Engine.h.obj
2>BulletCollision_Debug.lib(btManifoldResult.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in PCH.Engine.h.obj
2>BulletCollision_Debug.lib(btManifoldResult.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MD_DynamicRelease' in PCH.Engine.h.obj
2>BulletCollision_Debug.lib(btPolyhedralContactClipping.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in PCH.Engine.h.obj
2>BulletCollision_Debug.lib(btPolyhedralContactClipping.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MD_DynamicRelease' in PCH.Engine.h.obj
2>BulletCollision_Debug.lib(btCollisionShape.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in PCH.Engine.h.obj
2>BulletCollision_Debug.lib(btCollisionShape.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MD_DynamicRelease' in PCH.Engine.h.obj
2>BulletCollision_Debug.lib(btConvexShape.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in PCH.Engine.h.obj
2>BulletCollision_Debug.lib(btConvexShape.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MD_DynamicRelease' in PCH.Engine.h.obj
2>BulletCollision_Debug.lib(btCollisionAlgorithm.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in PCH.Engine.h.obj
2>BulletCollision_Debug.lib(btCollisionAlgorithm.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MD_DynamicRelease' in PCH.Engine.h.obj
2>BulletCollision_Debug.lib(btPolyhedralConvexShape.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in PCH.Engine.h.obj
2>BulletCollision_Debug.lib(btPolyhedralConvexShape.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MD_DynamicRelease' in PCH.Engine.h.obj
2>BulletCollision_Debug.lib(btHashedSimplePairCache.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in PCH.Engine.h.obj
2>BulletCollision_Debug.lib(btHashedSimplePairCache.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MD_DynamicRelease' in PCH.Engine.h.obj
2>BulletCollision_Debug.lib(btConvexPolyhedron.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in PCH.Engine.h.obj
2>BulletCollision_Debug.lib(btConvexPolyhedron.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MD_DynamicRelease' in PCH.Engine.h.obj
2>LinearMath_Debug.lib(btQuickprof.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in PCH.Engine.h.obj
2>LinearMath_Debug.lib(btQuickprof.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MD_DynamicRelease' in PCH.Engine.h.obj
2>LinearMath_Debug.lib(btConvexHullComputer.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in PCH.Engine.h.obj
2>LinearMath_Debug.lib(btConvexHullComputer.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MD_DynamicRelease' in PCH.Engine.h.obj
2>LinearMath_Debug.lib(btGeometryUtil.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in PCH.Engine.h.obj
2>LinearMath_Debug.lib(btGeometryUtil.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MD_DynamicRelease' in PCH.Engine.h.obj
2>     Creating library D:\WorkSpace\GitHubProjects\UE_4.16\UnrealEngine\Engine\Intermediate\Build\Win64\UE4Editor\Development\UE4Editor-Engine.suppressed.lib and object D:\WorkSpace\GitHubProjects\UE_4.16\UnrealEngine\Engine\Intermediate\Build\Win64\UE4Editor\Development\UE4Editor-Engine.suppressed.exp
2>D:\WorkSpace\GitHubProjects\UE_4.16\UnrealEngine\Engine\Binaries\Win64\UE4Editor-Engine.dll : fatal error LNK1319: 44 mismatches detected
2>ERROR : UBT error : Failed to produce item: D:\WorkSpace\GitHubProjects\UE_4.16\UnrealEngine\Engine\Binaries\Win64\UE4Editor-Engine.dll
2>  Total build time: 38.14 seconds (Local executor: 0.00 seconds)
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.MakeFile.Targets(37,5): error MSB3075: The command "..\..\Build\BatchFiles\Build.bat UE4Editor Win64 Development -waitmutex" exited with code 5. Please verify that you have sufficient rights to run this command.
========== Build: 1 succeeded, 1 failed, 2 up-to-date, 0 skipped ==========


However now I’m a step further, which is a good thing.