Building bulletphysics for windows on linux...

czuber
Posts: 6
Joined: Thu Mar 14, 2013 9:56 pm

Building bulletphysics for windows on linux...

Post by czuber »

Hi!
Sorry if anyone already sent this doubt (I really didn't find nothing about it here in forum)...

I am using Linux and I already have my libs ".a" OK. But now I want to make a windows version of my game, so I'm trying to compile the windows version of bulletPhysics with mingw, and runs my game on wine... (I don't need the demos, just the dlls...)

My steps until now were...
1- Downloaded and extracted the bullet-2.81-rev2613.zip (win version)
2- I tried to import all files (without cmake command) in code::blocks (configured to cross compile with mingw) just like I saw here: http://www.bulletphysics.org/Bullet/php ... f=9&t=3871 ->but I got a lot of compile errors :/
3- I tried to $cmake .. -G "MinGW Makefiles" but I got "CMake Error: Could not create named generator MinGW Makefiles"

So what do you recommend to do?
Thanks!

Czuber
red
Posts: 6
Joined: Wed Mar 13, 2013 9:18 pm

Re: Building bulletphysics for windows on linux...

Post by red »

try -G "Unix makefiles", I think that's what worked for me a few months back (using MSVC now, due to build issues with another dependency).
atari314
Posts: 1
Joined: Thu Aug 15, 2013 12:58 am

Re: Building bulletphysics for windows on linux...

Post by atari314 »

Hello Guys,

Sorry for resurrecting this thread, but since I couldn't find this info anywhere (and it took me a whole day to figure out), I guess it's worth posting.

Compiling Bullet Physics for Linux on Linux is easy and pretty straight forward:

Code: Select all

#download the bulletSDK.tgz
tar xvzf bullet-version.tgz
cd bullet-version/
cmake . -G "Unix Makefiles"
make
#libs and headers will be on the bullet-version/src/ dir
But compiling Bullet Physics for Windows on Linux using MinGW turned to be a goddamn nightmare. Well, here is how solve that :)

First, get the required tools.

For Debian/Ubuntu/Mint:

Code: Select all

sudo apt-get update && sudo apt-get install make cmake gcc-mingw32
For Fedora, I guess something like:

Code: Select all

su -c 'yum install make cmake mingw32-\*'
And for Opensuse, prolly:

Code: Select all

su -c 'zypper install make cmake mingw32'
Then download the current Bullet Physics SDK (Unix line endings):
https://code.google.com/p/bullet/downlo ... z&can=2&q=
or at https://code.google.com/p/bullet/downloads/list

Move it to your home and unpack it:

Code: Select all

mv /yourPathTo/bullet-2.81-rev2613.tgz ~/
cd ~/
tar xvzf bullet-2.81-rev2613.tgz
cd bullet-2.81-rev2613/
Now the trick to make it work is to edit the CMakeLists.txt file and add the following code after the first line: cmake_minimum_required(VERSION 2.4.3)

Code: Select all

# the name of the target operating system
SET(CMAKE_SYSTEM_NAME Windows)
 
# which compilers to use for C and C++
SET(CMAKE_C_COMPILER i586-mingw32msvc-gcc)
SET(CMAKE_CXX_COMPILER i586-mingw32msvc-g++)
SET(CMAKE_RC_COMPILER i586-mingw32msvc-windres)
 
# here is the target environment located
SET(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32)
 
# adjust the default behaviour of the FIND_XXX() commands:
# search headers and libraries in the target environment, search 
# programs in the host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
Don't forget to adjust the /usr/i686-w64-mingw32 for your distro path (this is the one I have on debian 7.1)
Save and close.

Now, the second trick, create the makefile without Extras and Demos (This will avoid the glut32 dependency that breaks the compilation around 30-40%. I srsly don't know how to fix that dep, since it requires the mingw32-glut that, apparently, don't exist on Debian, didn't check Ubuntu/Fedora/Opensuse tho. Installing the libglut-dev or freeglut also didn't help. So, as last resort, removing the glut dep all together.):

Code: Select all

cmake . -DBUILD_DEMOS:BOOL=OFF -DBUILD_EXTRAS:BOOL=OFF . -G "Unix Makefiles"
And make it:

Code: Select all

make
The libs (.a) will be store on /youPathTo/bullet-2.81-rev2613/lib/ (instead of the regular src dir).
The headers tho will be on the regular src dir (/youPathTo/bullet-2.81-rev2613/src).

When compiling your game using it, don't forget that the order of the bullet libs matter:

Code: Select all

-lBulletSoftBody -lBulletDynamics -lBulletCollision -lLinearMath
Cheers! :)

P.S.: I'd like to thank the devs for the great work on the Bullet Physics engine. It's awesome! Kudos!
Basroil
Posts: 463
Joined: Fri Nov 30, 2012 4:50 am

Re: Building bulletphysics for windows on linux...

Post by Basroil »

Could always just use Windows + Visual Studio Express, works right off the bat :wink: