Hello World...

User avatar
leo
Posts: 11
Joined: Fri Apr 17, 2009 4:12 pm
Location: europe

Hello World...

Post by leo »

Hi there!

I'm interested in programming using the bulletphysics library. While doing the first steps I was trying to run the "HelloWorld" program from the website (http://www.bulletphysics.com/mediawiki- ... ello_World). Unfortunately I got some errors like:
undefined reference to 'btAxisSweep3::btAxisSweep3(btVector3 const&, btVector3 const&, unsigned short, btOverlappingPairCache*, bool)'
First I thought that there is a linker problem and so I checked the paths of correctness (the files are in the concerning directories and I could open them!). Then I found out that the code looks like:

Code: Select all

#include <btBulletDynamicsCommon.h>

int main (void)
{

        btVector3 worldAabbMin(-10000,-10000,-10000);
        btVector3 worldAabbMax(10000,10000,10000);
        int maxProxies = 1024;
        btAxisSweep3* broadphase = new btAxisSweep3(worldAabbMin,worldAabbMax,maxProxies);

        ...

for me it looks like the btAxisSweep3 - constructor is not appropriate...?!
[btAxisSweep3(worldAabbMin,worldAabbMax,maxProxies) vs btAxisSweep3(btVector3 const&, btVector3 const&, unsigned short, btOverlappingPairCache*, bool)]
source: http://www.bulletphysics.com/Bullet/Bul ... weep3.html
Please correct me if I am wrong!

I tried to correct the implementation but was stumbling over the btOverlappingPairCache... it has no constructor - virtual function...

Hope anyone could give me a hint about that all!

Thanks
Leo
Dominik
Posts: 32
Joined: Fri Dec 19, 2008 2:51 pm

Re: Hello World...

Post by Dominik »

btAxisSweep3(const btVector3& worldAabbMin,const btVector3& worldAabbMax, unsigned short int maxHandles = 16384, btOverlappingPairCache* pairCache = 0, bool disableRaycastAccelerator = false)
The btAxisSweep3 construcot uses default arguments, so you don't have to specify the last ones. Your code should thus work fine (after all, it compiles successfully, and only the linking fails)

Are you sure you added the bullet libraries to your project?
User avatar
leo
Posts: 11
Joined: Fri Apr 17, 2009 4:12 pm
Location: europe

Re: Hello World...

Post by leo »

Hi Dominik,

thanks for your reply! Good argument with the compilation....
Concerning the linked libraries: I include (as default in the HelloWorld) btBulletDynamicsCommon.h file in which the rest of the includes for all the other .h files is defined. As far as I understand it there is no need to include these pathes explicitly - correct me if I'm wrong.

I even tried to include the path to the btAxisSweep.h file ... but still I got the error. Does it mean that the file could not be read? Or would it cause another error? Sorry I'm not so common with C/C++ things....

Another thing I recognised was that the directory bullet-2.73/lib/ is empty with the exception of a readme file. Shouldn't there be some files in like bulletmath.a, bulletcollision.a, bulletdynamics.a...?

Cheers Leo
Dominik
Posts: 32
Joined: Fri Dec 19, 2008 2:51 pm

Re: Hello World...

Post by Dominik »

if you use #include <*.h>, you do not use a library. In the header files, there are only declarations, while the libraries include the actual definitions (the stuff in the .cpp-files). So, you have to tell your application to use the bullet libraries (which is done during linking, when the compiler tries to resolve the function calls that were declared in included .h-files).

For this, you need the bullet libraries, which you get by building bullet. If your bullet/lib/ directory doesn't contain them after successfully building bullet, check the build directories, and copy the required files to the lib directory.

To tell the compiler to link the libraries when building bullet, you have to add them to the linker (windows/msvc) or add the necessary tags to the makefile (linux/gcc), If you need help on this, google can probably help you :)
User avatar
leo
Posts: 11
Joined: Fri Apr 17, 2009 4:12 pm
Location: europe

Re: Hello World...

Post by leo »

Hi Dominik,

I rebuilt the bullet library (version 2.74) on my Kubuntu 8.10 (I did as described here: http://bulletphysics.com/Bullet/BulletP ... c223854819).
  • cmake . –G “Unix Makefiles”
    ./autogen.sh
    ./configure
    make

    include path: bullet/src
    library path: bullet/src/.libs
    linked libs: libbulletdynamics, libbulletcollision, libbulletmath
Still the /bullet/lib/ folder is empty... but I found the libbulletdynamics, libbulletcollision, libbulletmath libraries in the bullet/src/.libs. Unfortunately there is still a (or a new) problem with the linker:

Code: Select all

Building target: TestBullet
Invoking: GCC C++ Linker
g++ -L/home/phmathys/bullet-2.74/src/.libs -o"TestBullet"  ./src/HelloWorld.o   -llibbulletdynamics -llibbulletcollision -llibbulletmath
/usr/bin/ld: cannot find -llibbulletdynamics
collect2: ld returned 1 exit status
make: *** [TestBullet] Error 1
make: Target `all' not remade because of errors.
Build complete for project TestBullet
I don't understand why the libraries cannot be found! And what has the /usr/bin/ld to do with this problem?

Cheers Philipp
cbuchner1
Posts: 17
Joined: Fri Apr 10, 2009 6:44 pm

Re: Hello World...

Post by cbuchner1 »

use -lbulletdynamics instead of -libbulletdynamics

same with the other libs

Don't forget to add library paths (-L option I believe) pointing to all folders where your compiled bullet libraries are located
User avatar
leo
Posts: 11
Joined: Fri Apr 17, 2009 4:12 pm
Location: europe

Re: Hello World...

Post by leo »

Problem solved... I had an error while installing and did not see it...
Cheers Leo