Repository: bulletphysics/bullet3

Issue:
DUSE_SOFT_BODY_MULTI_BODY_DYNAMICS_WORLD compiler error
I'm getting a compiler error on OS X when I define `DUSE_SOFT_BODY_MULTI_BODY_DYNAMICS_WORLD=ON` in my cmake build when trying to build commit  47eae8d, and the error is probably related to https://github.com/bulletphysics/bullet3/pull/850.

Full homebrew gist of installation process steps & output:
https://gist.github.com/ahundt/df791c901f89da9341f7760455c4bd9d

Relevant compiler error snippet:
```
cd /tmp/bullet-20170508-78186-o1zw4/build_cmake/examples/RobotSimulator && /usr/local/Homebrew/Library/Homebrew/shims/super/clang++  -DBT_ENABLE_CLSOCKET -DBT_ENABLE_ENET -DBT_USE_DOUBLE_PRECISION -DHAS_SOCKLEN_T -DUSE_GRAPHICAL_BENCHMARK -DUSE_SOFT_BODY_MULTI_BODY_DYNAMICS_WORLD -D_DARWIN -I/tmp/bullet-20170508-78186-o1zw4/src -I/tmp/bullet-20170508-78186-o1zw4/examples -I/tmp/bullet-20170508-78186-o1zw4/examples/ThirdPartyLibs -I/tmp/bullet-20170508-78186-o1zw4/examples/ThirdPartyLibs/enet/include -I/tmp/bullet-20170508-78186-o1zw4/examples/ThirdPartyLibs/clsocket/src  -DNDEBUG -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -mmacosx-version-min=10.11   -o CMakeFiles/App_RobotSimulator.dir/__/Importers/ImportMJCFDemo/BulletMJCFImporter.o -c /tmp/bullet-20170508-78186-o1zw4/examples/Importers/ImportMJCFDemo/BulletMJCFImporter.cpp
Undefined symbols for architecture x86_64:
  "btSoftBody::setTotalMass(double, bool)", referenced from:
      PhysicsServerCommandProcessor::processCommand(SharedMemoryCommand const&, SharedMemoryStatus&, char*, int) in PhysicsServerCommandProcessor.o
  "btSoftBody::appendMaterial()", referenced from:
      PhysicsServerCommandProcessor::processCommand(SharedMemoryCommand const&, SharedMemoryStatus&, char*, int) in PhysicsServerCommandProcessor.o
  "btSoftBody::randomizeConstraints()", referenced from:
      PhysicsServerCommandProcessor::processCommand(SharedMemoryCommand const&, SharedMemoryStatus&, char*, int) in PhysicsServerCommandProcessor.o
  "btSoftBody::generateBendingConstraints(int, btSoftBody::Material*)", referenced from:
      PhysicsServerCommandProcessor::processCommand(SharedMemoryCommand const&, SharedMemoryStatus&, char*, int) in PhysicsServerCommandProcessor.o
  "btSoftBody::scale(btVector3 const&)", referenced from:
      PhysicsServerCommandProcessor::processCommand(SharedMemoryCommand const&, SharedMemoryStatus&, char*, int) in PhysicsServerCommandProcessor.o
  "btSoftBody::rotate(btQuaternion const&)", referenced from:
      PhysicsServerCommandProcessor::processCommand(SharedMemoryCommand const&, SharedMemoryStatus&, char*, int) in PhysicsServerCommandProcessor.o
  "btSoftBody::translate(btVector3 const&)", referenced from:
      PhysicsServerCommandProcessor::processCommand(SharedMemoryCommand const&, SharedMemoryStatus&, char*, int) in PhysicsServerCommandProcessor.o
[ 83%] Building CXX object examples/SharedMemory/CMakeFiles/App_PhysicsServer_SharedMemory_GUI.dir/__/ExampleBrowser/OpenGLGuiHelper.o
  "btSoftBodyHelpers::CreateFromTriMesh(btSoftBodyWorldInfo&, double const*, int const*, int, bool)", referenced from:
      PhysicsServerCommandProcessor::processCommand(SharedMemoryCommand const&, SharedMemoryStatus&, char*, int) in PhysicsServerCommandProcessor.o
cd /tmp/bullet-20170508-78186-o1zw4/build_cmake/examples/SharedMemory && /usr/local/Homebrew/Library/Homebrew/shims/super/clang++  -DB3_USE_STANDALONE_EXAMPLE -DBT_USE_DOUBLE_PRECISION -DUSE_GRAPHICAL_BENCHMARK -DUSE_SOFT_BODY_MULTI_BODY_DYNAMICS_WORLD -I/tmp/bullet-20170508-78186-o1zw4/src -I/tmp/bullet-20170508-78186-o1zw4/examples/ThirdPartyLibs -I/tmp/bullet-20170508-78186-o1zw4/examples/ThirdPartyLibs/Glew  -DNDEBUG -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -mmacosx-version-min=10.11   -o CMakeFiles/App_PhysicsServer_SharedMemory_GUI.dir/__/ExampleBrowser/OpenGLGuiHelper.o -c /tmp/bullet-20170508-78186-o1zw4/examples/ExampleBrowser/OpenGLGuiHelper.cpp
  "btSoftBodyHelpers::Draw(btSoftBody*, btIDebugDraw*, int)", referenced from:
      PhysicsServerCommandProcessor::renderScene() in PhysicsServerCommandProcessor.o
  "btSoftMultiBodyDynamicsWorld::addSoftBody(btSoftBody*, int, int)", referenced from:
      PhysicsServerCommandProcessor::processCommand(SharedMemoryCommand const&, SharedMemoryStatus&, char*, int) in PhysicsServerCommandProcessor.o
  "btSoftMultiBodyDynamicsWorld::btSoftMultiBodyDynamicsWorld(btDispatcher*, btBroadphaseInterface*, btMultiBodyConstraintSolver*, btCollisionConfiguration*, btSoftBodySolver*)", referenced from:
      PhysicsServerCommandProcessor::createEmptyDynamicsWorld() in PhysicsServerCommandProcessor.o
  "btSoftBodyRigidBodyCollisionConfiguration::btSoftBodyRigidBodyCollisionConfiguration(btDefaultCollisionConstructionInfo const&)", referenced from:
      PhysicsServerCommandProcessor::createEmptyDynamicsWorld() in PhysicsServerCommandProcessor.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
```



Discussion:
Don't define DUSE_SOFT_BODY_MULTI_BODY_DYNAMICS_WORLD. Does it work then? For pybullet use pip install pybullet. See also the pybullet quickstart guide at pybullet.org
#1107 is with DUSE_SOFT_BODY_MULTI_BODY_DYNAMICS_WORLD disabled, but that one fails due to separate issues with the CMake configuration.

I use ROS and TensorFlow, which means using both the C & Python APIs, and I was hoping to use a single installation for integrating both.

I think this is likely solved fairly easily by adding whatever lib has a `btSoftBodyRigidBodyCollisionConfiguration` implementation to the `target_link_libraries()` call in whatever is compiling `PhysicsServerCommandProcessor`.
Sure, we should fix the cmake build. Why is pybullet not sufficient? pybullet works great with tensorflow. So you want a ROS - pybullet bridge? I think the c - api is not needed for that.
Which python version are you using and what flags/options do you enable exactly using cmake? cmake with standard out-of-the-box options should build, since it is in Appveyor and Travis.
 I think by default, the system version of Mac OSX is 32bit, but your cmake build seems to be 64bit.
I should be able to stick with python as long as I can manage performance bottlenecks, I'll explain why I asked. 

I work on a project called [costar](https://github.com/cpaxton/costar_stack) that uses more traditional approaches to planning and control with a combination of C++ and python code. For that reason, accessing a single scene instance from both python and C++ would be convenient but not a blocking requirement. A motivating example where C/C++ provides a substantial benefit would be if bullet could take in high bandwidth data like either a point cloud from an RGBD sensor or a mesh continuously updated via C/C++. An example of such a mesh would be one created with data from SLAM running outside bullet. 

I'm planning to modify costar to use a combination of something more traditional like the [Tasks robot model based control and constrained optimization library](https://github.com/jrl-umi3218/Tasks) alongside machine learning for decision making. Actually since it looks like some of the IK stuff in bullet may be in progress Tasks may be a useful/interesting/relevant resource. The new pybullet functionality looks like it will be a great resource for the machine learning / reinforcement learning component, so thanks for the great work!

My cmake config was the same as #1107 I ran into this error first and it was with the addition of `-DUSE_SOFT_BODY_MULTI_BODY_DYNAMICS_WORLD=ON`.

I actually encountered this compiler error both in Linux and OS X. #1107 is OS X only.

Here were the Linux flags and a [script to reproduce](https://github.com/ahundt/robotics_setup/blob/master/bullet.sh), though the soft body flag is removed in the linked code so I can compile on linux:

```

cmake .. \
-DCMAKE_C_FLAGS_RELEASE=-DNDEBUG \
-DCMAKE_CXX_FLAGS_RELEASE=-DNDEBUG \
-DCMAKE_INSTALL_PREFIX=/usr/local \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_FIND_FRAMEWORK=LAST \
-DCMAKE_VERBOSE_MAKEFILE=ON \
-Wno-dev \
-DHAVE_CLOCK_GETTIME:INTERNAL=0 \
-DINSTALL_EXTRA_LIBS=ON \
-DBUILD_UNIT_TESTS=OFF \
-DUSE_DOUBLE_PRECISION=ON \
-DBUILD_BULLET2_DEMOS=ON \
-DBUILD_PYBULLET=ON \
-DBUILD_PYBULLET_NUMPY=ON \
-DBUILD_PYBULLET_CLSOCKET=ON \
-DBUILD_PYBULLET_ENET=ON \
-DBUILD_ENET=ON \
-DBUILD_CLSOCKET=ON \
-DBUILD_SHARED_LIBS=ON \
-DUSE_SOFT_BODY_MULTI_BODY_DYNAMICS_WORLD=ON
```


Patch:
diff --git a/examples/SharedMemory/CMakeLists.txt b/examples/SharedMemory/CMakeLists.txt
index 1bd6265725..3f1517a61b 100644
--- a/examples/SharedMemory/CMakeLists.txt
+++ b/examples/SharedMemory/CMakeLists.txt
@@ -62,7 +62,7 @@ SET(SharedMemory_SRCS
 	../Importers/ImportMJCFDemo/BulletMJCFImporter.cpp
 	../Importers/ImportMJCFDemo/BulletMJCFImporter.h
 	../Utils/b3ResourcePath.cpp
-	../Utils/b3Clock.cpp	
+	../Utils/b3Clock.cpp
 	../Utils/RobotLoggingUtil.cpp
 	../Utils/RobotLoggingUtil.h
 	../Utils/ChromeTraceUtil.cpp
@@ -75,13 +75,13 @@ SET(SharedMemory_SRCS
 	../Importers/ImportSTLDemo/LoadMeshFromSTL.h
 	../Importers/ImportColladaDemo/LoadMeshFromCollada.cpp
 	../Importers/ImportColladaDemo/ColladaGraphicsInstance.h
-	../ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp	
+	../ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp
 	../ThirdPartyLibs/tinyxml/tinystr.cpp
 	../ThirdPartyLibs/tinyxml/tinyxml.cpp
 	../ThirdPartyLibs/tinyxml/tinyxmlerror.cpp
 	../ThirdPartyLibs/tinyxml/tinyxmlparser.cpp
 	../Importers/ImportMeshUtility/b3ImportMeshUtility.cpp
-	../ThirdPartyLibs/stb_image/stb_image.cpp  
+	../ThirdPartyLibs/stb_image/stb_image.cpp
 	../MultiThreading/b3ThreadSupportInterface.cpp
 	../MultiThreading/b3ThreadSupportInterface.h
 )
@@ -95,6 +95,10 @@ LINK_LIBRARIES(
  Bullet3Common BulletWorldImporter BulletFileLoader BulletInverseDynamicsUtils BulletInverseDynamics BulletDynamics BulletCollision LinearMath BussIK
 )
 
+IF (USE_SOFT_BODY_MULTI_BODY_DYNAMICS_WORLD)
+	LINK_LIBRARIES(BulletSoftBody)
+ENDIF()
+
 IF (WIN32)
         ADD_EXECUTABLE(App_PhysicsServer_SharedMemory
                 ${SharedMemory_SRCS}
@@ -112,7 +116,7 @@ ELSE(WIN32)
 	               			../MultiThreading/b3PosixThreadSupport.h
 			                main.cpp
 			        )
-							
+
         ELSE(APPLE)
                                 LINK_LIBRARIES(  pthread ${DL} )
 			        ADD_EXECUTABLE(App_PhysicsServer_SharedMemory
@@ -152,7 +156,7 @@ LINK_LIBRARIES(
 IF (WIN32)
  				ADD_DEFINITIONS(-DGLEW_STATIC)
 				LINK_LIBRARIES( ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} )
-	
+
         ADD_EXECUTABLE(App_PhysicsServer_SharedMemory_GUI
                 ${SharedMemory_SRCS}
 								../StandaloneMain/main_opengl_single_example.cpp
@@ -169,23 +173,23 @@ ELSE(WIN32)
 			        FIND_LIBRARY(COCOA NAMES Cocoa)
               MESSAGE(${COCOA})
               LINK_LIBRARIES(${COCOA} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY})
-                
+
 			        ADD_EXECUTABLE(App_PhysicsServer_SharedMemory_GUI
 			                ${SharedMemory_SRCS}
 	               			../StandaloneMain/main_opengl_single_example.cpp
 											../ExampleBrowser/OpenGLGuiHelper.cpp
 											../ExampleBrowser/GL_ShapeDrawer.cpp
-											../ExampleBrowser/CollisionShape2TriangleMesh.cpp					
+											../ExampleBrowser/CollisionShape2TriangleMesh.cpp
 			                ../MultiThreading/b3PosixThreadSupport.cpp
 	               			../MultiThreading/b3PosixThreadSupport.h
 			        )
-							
+
         ELSE(APPLE)
 				LINK_LIBRARIES(  pthread ${DL} )
          			ADD_DEFINITIONS("-DGLEW_INIT_OPENGL11_FUNCTIONS=1")
               ADD_DEFINITIONS("-DGLEW_STATIC")
               ADD_DEFINITIONS("-DGLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS=1")
-                
+
 			        ADD_EXECUTABLE(App_PhysicsServer_SharedMemory_GUI
 			                ${SharedMemory_SRCS}
 	              			../StandaloneMain/main_opengl_single_example.cpp
@@ -215,7 +219,7 @@ INCLUDE_DIRECTORIES(
 	${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs
 	${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/Glew
 	${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/openvr/headers
-	${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/openvr/samples/shared		
+	${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/openvr/samples/shared
 )
 
 
@@ -233,7 +237,7 @@ LINK_LIBRARIES(
 					LINK_DIRECTORIES(${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/openvr/lib/win64)
 				ELSE(CMAKE_CL_64)
 					LINK_DIRECTORIES(${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/openvr/lib/win32)
-				ENDIF(CMAKE_CL_64)			
+				ENDIF(CMAKE_CL_64)
         ADD_EXECUTABLE(App_PhysicsServer_SharedMemory_VR
                 ${SharedMemory_SRCS}
           ../StandaloneMain/hellovr_opengl_main.cpp
@@ -250,12 +254,12 @@ LINK_LIBRARIES(
 					../ThirdPartyLibs/openvr/samples/shared/pathtools.cpp
 					../ThirdPartyLibs/openvr/samples/shared/pathtools.h
 					../ThirdPartyLibs/openvr/samples/shared/strtools.cpp
-					../ThirdPartyLibs/openvr/samples/shared/strtools.h					
+					../ThirdPartyLibs/openvr/samples/shared/strtools.h
 					../ThirdPartyLibs/openvr/samples/shared/Vectors.h
 						../MultiThreading/b3Win32ThreadSupport.cpp
 						../MultiThreading/b3Win32ThreadSupport.h
 	          ${BULLET_PHYSICS_SOURCE_DIR}/build3/bullet.rc
-        )			
+        )
 
 
 IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
@@ -272,7 +276,7 @@ IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
 			COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/openvr/bin/win32/openvr_api.dll  ${CMAKE_CURRENT_BINARY_DIR}/openvr_api.dll
 		)
 	ENDIF(CMAKE_CL_64)
-	
+
 	ADD_CUSTOM_COMMAND(
                 TARGET App_PhysicsServer_SharedMemory_VR
                 POST_BUILD