Building OgreBullet on Ubuntu
omniyo
20-03-2011 19:01:03
Firstly I'm sorry for my English.
I'm trying to install Bullet+OgreBullet on Ubuntu 10.04.
My Ogre version is 1.7.2
I've followed these steps (as some people indicated in this forum) but i couldn't compile my project without a warning from the compiler pointing out it couldn't found the library. I'm not using any IDE, just a makefile, and it worked for OGRE and OIS (I do need this way).
1) Install BULLET dependencies.
2) Download BULLET from svn
cmake . -G "Unix Makefiles"
make -j4
sudo make install
Then, I test the BULLET demo and it works.
I've observed that the installation folder, by default, is /usr/local/ (same as OGRE). So I update this:
export CPPFLAGS="-I/usr/local/include/OGRE -I/usr/local/include"
export LDFLAGS="-L/usr/local/lib/OGRE -L/usr/local/lib"
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig"
Copy extras:
sudo cp ./Extras/ConvexDecomposition/*.h /usr/local/include/bullet/
At this moment my file "bullet.pc" has the followings libs and Cflags:
Libs: -L/usr/local/lib -lBulletSoftBody -lBulletDynamics -lBulletCollision -lLinearMath
Cflags: -I/usr/local/include/bullet
Generate makefiles, configure build and compile:
chmod 755 autogen.sh
./autogen.sh
./configure --prefix=/usr/local
make
sudo make install
Once installed, I add to the makefile of my proyect the dependencies:
Before:
HDRDIR:= include
CXXFLAGS := -Wall `pkg-config --cflags OGRE` -fexceptions -I$(HDRDIR)
LDFLAGS := `pkg-config --cflags OGRE` -L/bin/Debug -L/bin/Release -s
LDFLAGS += -lGL -lstdc++ -lOgreMain -lOIS
After:
HDRDIR:= include
CXXFLAGS := -Wall `pkg-config --cflags OGRE` `pkg-config --cflags bullet` -fexceptions -I$(HDRDIR)
LDFLAGS := `pkg-config --cflags OGRE` -L/bin/Debug -L/bin/Release -s
LDFLAGS += -lGL -lstdc++ -lOgreMain -lOIS
LDFLAGS += -lBulletSoftBody -lBulletDynamics -lBulletCollision -lLinearMath
To test installation, i write in one of my headers files:
#include "OgreBulletDynamicsRigidBody.h"
But at compiling time, that file doesn't exists.
I think the installation is ok, because i don't have any error, but i'm pretty sure something is failling at linking. Can anybody help me?
Thanks in advance.
dermont
21-03-2011 08:25:00
I think you may be missing an include to the OgreBullet headers, from the command line try:
pkg-config --cflags --libs --modversion OgreBullet
Building an example from the command line:
g++ -o tutorial2 -I. `pkg-config --cflags --libs OGRE OIS bullet OgreBullet` Tutorial2.cpp
Edit:
Also rather than manually copying across the the extra bullet libs you can so in your CMake command (I think) with "INSTALL_EXTRA_LIBS", something like:
cmake . -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/media/sda8/Libraries/Physics/bullet-svn-test-sdk -DBUILD_DEMOS=FALSE -DINSTALL_EXTRA_LIBS=TRUE ../bullet-svn-r2243
and a simple Makefile, you can remove the PKG_CONFIG_PATH/rpath stuff I have Ogre installed in a non-standard location.
CC = g++
FILES = Tutorial2.cpp
OUT_EXE = MyDemo
OBJECTS=$(FILES:.cpp=.o)
OGRE_PATH=/media/sda8/Libraries/OGRE/sdk/v1-7
PKG_CONFIG_PATH := $(OGRE_PATH)/lib/pkgconfig:$(PKG_CONFIG_PATH)
export PKG_CONFIG_PATH
CXXFLAGS=`pkg-config --cflags OGRE OIS bullet OgreBullet` -I./
LDFLAGS=`pkg-config --libs OGRE OIS bullet OgreBullet` -Wl,-rpath=${OGRE_PATH}/lib
build: $(FILES) $(OUT_EXE)
$(OUT_EXE): $(OBJECTS)
$(CC) -o $(OUT_EXE) $(OBJECTS) $(LDFLAGS)
.cpp.o:
$(CC) -c $(CXXFLAGS) $< -o $@
clean:
rm -f *.o $(OUT_EXE)
rebuild: clean build
omniyo
21-03-2011 10:26:07
Thanks dermont,
I've tried pkg-config --cflags --libs --modversion OgreBullet and this is what i get:
"Package OgreBullet was not found in the pkg-config search path.
Perhaps you should add the directory containing 'OgreBullet.pc' to the PKG_CONFIG_PATH environment variable
No package 'OgreBullet' found"
My pkgconfig folder is located here: /usr/local/lib/ and BULLET-related files i just have "bullet.pc" which doesn't contain anything about OgreBullet, only bullet itself.
Should I have an "OgreBullet.pc" or a reference on "bullet.pc"? does this mean it isn't well installed?
dermont
21-03-2011 11:05:03
Thanks dermont,
I've tried pkg-config --cflags --libs --modversion OgreBullet and this is what i get:
"Package OgreBullet was not found in the pkg-config search path.
Perhaps you should add the directory containing 'OgreBullet.pc' to the PKG_CONFIG_PATH environment variable
No package 'OgreBullet' found"
My pkgconfig folder is located here: /usr/local/lib/ and BULLET-related files i just have "bullet.pc" which doesn't contain anything about OgreBullet, only bullet itself.
Should I have an "OgreBullet.pc" or a reference on "bullet.pc"? does this mean it isn't well installed?
AFAIK OgreBullet.pc should have been installed to /usr/local/lib/pkgconfig. Re-run your OgreBullet install and check if there any problems.
Your OgreBullet.pc pkgconfig file should look something like this:
prefix=/usr/local
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: OgreBullet
Description: Ogre's wrapper for Bullet library
Version: 0.2
Libs: -L${libdir} -lOgreBulletCol -lOgreBulletDyn
Cflags: -I${includedir}/OgreBullet/Collisions -I${includedir}/OgreBullet/Dynamics
>> pkg-config --cflags --libs OgreBullet
>> -I/usr/local/include/OgreBullet/Collisions -I/usr/local/include/OgreBullet/Dynamics -L/usr/local/lib -lOgreBulletCol -lOgreBulletDyn
omniyo
21-03-2011 13:22:57
I've rebuilt my installation, and now i have OgreBullet.pc (it seems i used an old revision).
I've adapted the makefile according to your advice.
# Project name
PROYECTO := futbolesasi
# Folders
OBJDIR := obj
SRCDIR := src
HDRDIR := include
#Compiler and Flags
CXX := g++
CXXFLAGS := -Wall `pkg-config --cflags OGRE bullet OgreBullet` -fexceptions -I$(HDRDIR)
#Dependencies file
DEPFILE := dependencias
# Linker Flags
LDFLAGS := `pkg-config --libs OGRE bullet OgreBullet` -L/bin/Debug -L/bin/Release -s
LDFLAGS += -lGL -lstdc++ -lOgreMain -lOIS
LDFLAGS += -lOgreBulletCol -lOgreBulletDyn
# Output colors
COLOR_FIN := \033[00m
COLOR_OK := \033[01;32m
COLOR_ERROR := \033[01;31m
COLOR_AVISO := \033[01;33m
COLOR_COMP := \033[01;34m
COLOR_ENL := \033[01;35m
# Compilation mode, debug (default)
ifeq ($(modo), release)
CXXFLAGS += -O2 -D_RELEASE
else
modo := debug
CXXFLAGS += -g -D_DEBUG
endif
# Select source files
SRCS := $(notdir $(shell ls -t $(SRCDIR)/*.cpp))
OBJS := $(addprefix $(OBJDIR)/, $(addsuffix .o,$(basename $(SRCS))))
.PHONY:all
all: informacion gen_deps $(PROYECTO)
# Check compilation mode
informacion:
ifneq ($(modo),release)
ifneq ($(modo),debug)
@echo ''
@echo -e '$(COLOR_ERROR)Modo de compilación inválido.$(COLOR_FIN)'
@echo "Por favor usa 'make [modo=release|debug]'"
@echo ''
@exit 1
endif
endif
@echo ''
@echo -e 'Compilando en modo $(COLOR_AVISO)"$(modo)"$(COLOR_FIN)'
@echo '..........................'
@echo ''
gen_deps:
@echo ''
@echo -e '$(COLOR_AVISO)Generando dependencias$(COLOR_FIN)...'
@gcc -MM -I$(HDRDIR) $(shell ls -t $(SRCDIR)/*.cpp) | sed 's/^\([a-zA-Z]\+.o:\)/$(OBJDIR)\/\1/g' > $(DEPFILE)
@echo ''
# Compilation
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp
@echo -e '$(COLOR_COMP)Compilando$(COLOR_FIN)... $(notdir $<)'
@mkdir -p $(OBJDIR)
@$(CXX) $(CXXFLAGS) -c $< -o $@
# Linking
$(PROYECTO): $(OBJS)
@echo ''
@echo -e '$(COLOR_ENL)Enlazando$(COLOR_FIN)...'
@echo ''
@$(CXX) $(LDFLAGS) -o $@ $^ $(LIBS)
@echo -e '$(COLOR_OK)Terminado.$(COLOR_FIN)'
@echo ''
# Cleaning
.PHONY:clean
clean:
@echo ''
@echo -e '$(COLOR_AVISO)Limpiando$(COLOR_FIN)...'
@echo ''
rm $(OBJS) $(PROYECTO) $(OBJDIR) *~ -rf
@echo ''
@echo -e '$(COLOR_OK)Terminado.$(COLOR_FIN)'
@echo ''
-include $(DEPFILE)
The only thing i've added (in a header file) to my code in order to test the installation is:
#include "OgreBulletDynamicsRigidBody.h"
and a variable:
OgreBulletDynamics::DynamicsWorld *mWorld;
Should this run?
And i get these erros at command line:
1) OgreBulletDynamicsRigidBody.h: file or folder does not exist.
2) undefined reference to 'ConvexBuilder::~ConvexBuilder()'
3) undefined reference to 'ConvexBuilder::process(ConvexDecomposition::DecompDesc const&)'
4) undefined reference to 'ConvexBuilder::ConvexBuilder(ConvexDecomposition::ConvexDecompInterface*)'
collect2: ld returned 1 exit status
Thanks
dermont
21-03-2011 16:03:26
The only thing i've added (in a header file) to my code in order to test the installation is:
#include "OgreBulletDynamicsRigidBody.h"
and a variable:
OgreBulletDynamics::DynamicsWorld *mWorld;
Should this run?
Of course it won't.
And i get these erros at command line:
1) OgreBulletDynamicsRigidBody.h: file or folder does not exist.
2) undefined reference to 'ConvexBuilder::~ConvexBuilder()'
3) undefined reference to 'ConvexBuilder::process(ConvexDecomposition::DecompDesc const&)'
4) undefined reference to 'ConvexBuilder::ConvexBuilder(ConvexDecomposition::ConvexDecompInterface*)'
collect2: ld returned 1 exit status
1) OgreBulletDynamicsRigidBody.h: file or folder does not exist.
Check if the header is in /usr/local/include/OgreBullet/Dynamics.
If not, I'm guessing that the headers have not been installed correctly, it may be that your OgreBullet build has failed and you have run make install which has only done a partial install, re-run make and if you see errors such as the following:
/media/sda8/tutorial/ogrebullet_src/Collisions/src/.libs/libOgreBulletCol.so: undefined reference to `ConvexBuilder::~ConvexBuilder()'
/media/sda8/tutorial/ogrebullet_src/Collisions/src/.libs/libOgreBulletCol.so: undefined reference to `ConvexBuilder::process(ConvexDecomposition::DecompDesc const&)'
/media/sda8/tutorial/ogrebullet_src/Collisions/src/.libs/libOgreBulletCol.so: undefined reference to `ConvexBuilder::ConvexBuilder(ConvexDecomposition::ConvexDecompInterface*)'
If so then:
1) >> sudo make uninstall
>> make clean
2) copy ./Extras/ConvexDecomposition/libConvexDecomposition.a to usr/local/lib
(you would be better doing this via the bullet CMake options)
3) Update Collisions/src/Makefile.am to link against ConvexDecomposition (may be different if static lib)
libOgreBulletCol_la_LIBADD = \
$(OGRE_LIBS) \
$(bullet_LIBS) \
-lConvexDecomposition
4) >> ./autogen.sh
>> CXXFLAGS=-I/usr/local/include/bullet/ConvexDecomposition ./configure (or wherever the convexdecomposition headers are)
>> make
>> sudo make install
>> sudo ldconfig
[/list:u]
Attached is the example from the wiki.
omniyo
22-03-2011 11:12:33
Definitely
it works
Firstly, thanks to Dermont.
I'm going to write here the whole process in order to help people who has the same difficulties as me:
1) Install dependencies:
sudo apt-get install cmake autoconf automake libtool libgl1-mesa-dev freeglut3-dev
2) Download Bullet:
http://bullet.googlecode.com/files/bullet-2.77.tgz
3) Compile and install Bullet:
cmake . -G "Unix Makefiles" -DBUILD_DEMOS=FALSE -DINSTALL_EXTRA_LIBS=TRUE
make -j4
sudo make install
4) Download OgreBullet:
http://ogreaddons.svn.sourceforge.net/viewvc/ogreaddons/trunk/ogrebullet/?view=tar
5) Update Collisions/src/Makefile.am
libOgreBulletCol_la_LIBADD = \
$(OGRE_LIBS) \
$(bullet_LIBS) \
-lConvexDecomposition
7) >> chmod 755 autogen.sh
8 ) >> ./autogen.sh
9) >> CXXFLAGS=-I/usr/local/include/bullet/ConvexDecomposition ./configure
10) >> make
11) >> sudo make install
12) >> sudo ldconfig
If you want to test your installation you will have to download the tutorial:
http://www.ogre3d.org/addonforums/download/file.php?id=816
And then, before compiling:
1) Download and install ogre samples (if you haven't):
sudo apt-get install ogre-samples-media ogre-samples-bin ogre-samples-source
2) Change OGRE_PATH in the Makefile (in my case: /usr/local )
3) Change PluginFolder en plugins.cfg (in my case: /usr/local/lib/OGRE )
4) Change resource locations in resources.cfg (in my case: /usr/share/OGRE/media/...... ) (wherever you have installed the samples)
5) >> make
Once you are inside the tutorial demo, press 'b' key to throw a box and admire the result of physics and collisions.
Correct me if i'm wrong at any point.
Cheers!
dermont
31-03-2011 14:48:06
Attached is a patch for Linux to build the OgreBullet demo (if you are interested) . I haven't tried this on a clean checkout of the source so if there any problems I'll take another look.
omniyo
31-03-2011 20:29:43
Hi again dermont,
Thanks for the patch and for detailing how to get doxygen documentation of OgreBullet, at least it's something.
Sorry for my ignorance, but how do I apply the patch file? and where from?
Thanks in advance
dermont
01-04-2011 04:59:03
Hi again dermont,
Thanks for the patch and for detailing how to get doxygen documentation of OgreBullet, at least it's something.
Sorry for my ignorance, but how do I apply the patch file? and where from?
Thanks in advance
Assuming you have a fresh copy of the OgreBullet svn source, copy the linux_demo.patch to your top source dir (i.e. where autogen.sh is).
>> patch -p0 < linux_demo.patch
>> chmod a+x autogen.sh
>> ./autogen.sh
>> ./configure (no need for CXXFLAGS ConvexDecomposition include if ConvexDecomposition installed)
>> make
>> sudo make install
>> sudo ldconfig
>> cd bin
>> ./OgreBullet_Demo
You may have to updated plugins.cfg to point to your installed libs and resources.cfg to point to your resources (not sure if this is required maybe all you need is Demos/Media/*) .
Erasmuz
01-04-2011 07:19:53
I too have been struggling at the same point for most of the night now.
Trying with the patch applied yields a result of the build process eventually complaining and saying:
/usr/bin/ld: cannot find -lConvexDecomposition
So taking it out and continuing the build allows for the build process to finish, but then compiling projects still of course complain:
/usr/local/lib/libOgreBulletCol.so: undefined reference to `ConvexBuilder::~ConvexBuilder()'
/usr/local/lib/libOgreBulletCol.so: undefined reference to `ConvexBuilder::process(ConvexDecomposition::DecompDesc const&)'
/usr/local/lib/libOgreBulletCol.so: undefined reference to `ConvexBuilder::ConvexBuilder(ConvexDecomposition::ConvexDecompInterface*)'
Any more help you could shed on this issue would be greatly appreciated.
Thanks!
omniyo
01-04-2011 11:41:02
It works.
what i just changed are the folder where the resources are.
Thanks dermont.
Erasmuz... it is pretty strange... have you follow the installation process written in this topic?
Erasmuz
01-04-2011 19:17:11
Hey guys,
No luck still. I restarted the process fresh making sure I followed the steps again. I noticed before I was using 2.76, so I updated to 2.77. Everything seemed to be working (at least I think it got farther than before), but now it crashes with
undefined reference to `btHingeConstraint::btHingeConstraint(btRigidBody&, btRigidBody&, btVector3 const&, btVector3 const&, btVector3 const&, btVector3 const&, bool)'
Any ideas? I think for what ever reason it might not be seeing newer stuff? I ran sudo ldconfig and made sure everything else looked correct, but still no successful build.
Thanks in advance for any help.
dermont
01-04-2011 20:43:40
Did you run make clean before rebuilding OgreBullet? Can you post your full build error message.
Erasmuz
01-04-2011 21:00:18
I just finished re-trying and making sure I ran make clean first (thought I did, but wasn't sure). Here's my output...
g++ -DHAVE_CONFIG_H -I. -I.. -pthread -I/usr/local/include -I/usr/local/include/OGRE -I/usr/local/include/bullet -I/usr/local/include -I/usr/include/OIS -I../Dynamics/include -I../Dynamics/include/Constraints -I../Collisions/include -I../Collisions/include/Debug -I../Collisions/include/Shapes -I../Collisions/include/Utils -I../Demos/include -I../Demos/Dynamics_Demos/include -I/usr/local/include/bullet/ConvexDecomposition -MT Terrain_Demo.o -MD -MP -MF .deps/Terrain_Demo.Tpo -c -o Terrain_Demo.o `test -f 'Dynamics_Demos/src/Terrain_Demo.cpp' || echo './'`Dynamics_Demos/src/Terrain_Demo.cpp
mv -f .deps/Terrain_Demo.Tpo .deps/Terrain_Demo.Po
/bin/bash ../libtool --tag=CXX --mode=link g++ -I/usr/local/include/bullet/ConvexDecomposition -L../Dynamics/src -L../Collisions/src -o OgreBullet_Demo BetaGUI.o OgreBulletApplication.o OgreBulletInputListener.o OgreBulletGuiListener.o OgreBulletListener.o Constraints_Demo.o main.o Primitives_Demo.o Vehicle_Demo.o TriMesh_Demo.o Ragdoll_Demo.o Terrain_Demo.o -lOgreBulletDyn -lOgreBulletCol -L/usr/local/lib -lOgreMain -lpthread -L/usr/local/lib -lBulletSoftBody -lBulletDynamics -lBulletCollision -lLinearMath -lOIS
libtool: link: g++ -I/usr/local/include/bullet/ConvexDecomposition -o .libs/OgreBullet_Demo BetaGUI.o OgreBulletApplication.o OgreBulletInputListener.o OgreBulletGuiListener.o OgreBulletListener.o Constraints_Demo.o main.o Primitives_Demo.o Vehicle_Demo.o TriMesh_Demo.o Ragdoll_Demo.o Terrain_Demo.o -L/home/aaron/Desktop/ogrebullet/Dynamics/src -L/home/aaron/Desktop/ogrebullet/Collisions/src /home/aaron/Desktop/ogrebullet/Dynamics/src/.libs/libOgreBulletDyn.so /home/aaron/Desktop/ogrebullet/Collisions/src/.libs/libOgreBulletCol.so -L/usr/local/lib -lOgreMain -lpthread -lBulletSoftBody -lBulletDynamics -lBulletCollision -lLinearMath /usr/lib/libOIS.so
/home/aaron/Desktop/ogrebullet/Dynamics/src/.libs/libOgreBulletDyn.so: undefined reference to `btHingeConstraint::btHingeConstraint(btRigidBody&, btVector3 const&, btVector3 const&, bool)'
/home/aaron/Desktop/ogrebullet/Dynamics/src/.libs/libOgreBulletDyn.so: undefined reference to `btHingeConstraint::btHingeConstraint(btRigidBody&, btRigidBody&, btVector3 const&, btVector3 const&, btVector3 const&, btVector3 const&, bool)'
collect2: ld returned 1 exit status
make[2]: *** [OgreBullet_Demo] Error 1
make[2]: Leaving directory `/home/aaron/Desktop/ogrebullet/Demos'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/aaron/Desktop/ogrebullet'
make: *** [all] Error 2
Is that enough of the error message? I can post more, but tried to just capture the last relevant bit.
dermont
01-04-2011 22:10:50
Yes the error message you posted is enough. I don't know why you are getting the undefined references to btHingeConstraint. The only thing I can think of is that there is a problem with your bullet installation, though it's more likely that I've screwed uo somewhere with the patch.
You have run all the steps for OgreBullet ./autogen.sh etc after installing the new version of bullet so it appears to be a problem with the demo/patch. You could try editing the top source Makefile.am and removing the Demos build, e.g:
SUBDIRS = Collisions Dynamics
Then ./autogen.sh etc should let you install, you can try building the tutorial demo in this thread to see if you still encounter the same problem.