Results 1 to 11 of 11

Thread: Qt and Bullet linking problem

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    387
    Thanks
    101
    Thanked 15 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Qt and Bullet linking problem

    Hello!

    I'm struggling with a linker error. I don't fully understand the problem and I'm out of ideas what else to try. Can someone please give advice?

    The problem looks like this. I moved a Qt / Bullet Physics project to a new Win7 64 bit PC. Before I was developing it on a 32 bit Win7. The project compiles nicely there and runs without problems. I use the same Qt version 2010.05 on the new PC and I used the MinGW 4.4.0 that comes with it to compile the Bullet Physics library that is linked to my project. But when I build the project, I get linker errors like this:

    ./release\Joint.o:Joint.cpp:(.text+0x22e7): undefined reference to `btRigidBody::btRigidBody(float, btMotionState*, btCollisionShape*, btVector3 const&)'
    ./release\GroundPlane.o:GroundPlane.cpp:(.text+0x246 ): undefined reference to `btStaticPlaneShape::btStaticPlaneShape(btVector3 const&, float)'
    The corresponding lines in the source look like this:

    Qt Code:
    1. btRigidBody rigidBody = new btRigidBody(mass, &motionState, collisionShape, inertia);
    2. btCollisionShape collisionShape = new btStaticPlaneShape(btVector3(0, 0, 1), 0);
    To copy to clipboard, switch view to plain text mode 

    I don't think the problem is in the source though, since it compiles and links perfectly fine on the 32 bit system. And it's not like every call to the Bullet library produces a linker error. Only a very few pop up and strangely, all of them have a float parameter, where actually a btScalar (Bullet's on floating point) should be used. The main difference between the old and new environment is the bitness, so I suspect that the problem may be coming from there, but I have no idea what exactly it could be. Any ideas where to dig next?

    Thanks,
    Cruz

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Qt and Bullet linking problem

    I assume that these bt* classes are part of the Bullet library. That library needs to built and/or installed on the machine and the Qt project file LIBS variable set so the linker will find the library.

  3. #3
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    387
    Thanks
    101
    Thanked 15 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt and Bullet linking problem

    Yes I did that. I compiled the Bullet library with the same MinGW version that I use to compile my project. LIBS is set and I'm sure it's correct. It must be something else.
    In fact, I tried setting a wrong LIBS on purpose and yes, in that case it showers linker errors from every place I access the Bullet library. Setting LIBS back to the correct value reduces the errors to a few, all of which have a float variable as an argument where in the Bullet documentation it should be a btScalar. I don't understand this part and I'm pretty sure it's related to the actual problem.
    Last edited by Cruz; 2nd January 2014 at 21:18.

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Qt and Bullet linking problem

    It must be something else.
    Famous last words. The error message from your linker is explicit... it cannot find the library.

    Where is Bullet built and installed and what is the LIBS value in your PRO file.

  5. #5
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    387
    Thanks
    101
    Thanked 15 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt and Bullet linking problem

    Bullet is in C:\usr\lib and the related part of my .pro looks like this:

    win32:LIBS += -Lc:/usr/lib
    win32:LIBS += -lBulletDynamics -lBulletCollision -lLinearMath

    The linker must find the library because it doesn't complain about every Bullet call, only a few selected ones. I edited my last post, maybe you didn't see that yet, and tried setting LIBS to a wrong value on purpose to check this.

  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Qt and Bullet linking problem

    I edited my last post, maybe you didn't see that yet, and tried setting LIBS to a wrong value on purpose to check this.
    Yep, you edited it after I posted.

    You are using the same (very old) 32-bit compiler on your 64-bit system. It should be generating the same 32-bit libs/exes for the same input. However, the definition of btScalar can map to either float or double depending on configuration switches (from btScalar.h):
    Qt Code:
    1. #if defined(BT_USE_DOUBLE_PRECISION)
    2. typedef double btScalar;
    3. //this number could be bigger in double precision
    4. #define BT_LARGE_FLOAT 1e30
    5. #else
    6. typedef float btScalar;
    7. //keep BT_LARGE_FLOAT*BT_LARGE_FLOAT < FLT_MAX
    8. #define BT_LARGE_FLOAT 1e18f
    9. #endif
    To copy to clipboard, switch view to plain text mode 
    I assume these are given to, or guessed by, CMake at library build time.

    Is your "mass" variable declared:
    Qt Code:
    1. float mass;
    2. // or
    3. btScalar mass;
    To copy to clipboard, switch view to plain text mode 

  7. The following user says thank you to ChrisW67 for this useful post:

    Cruz (2nd January 2014)

Similar Threads

  1. Qt linking problem
    By LovesTha in forum Newbie
    Replies: 3
    Last Post: 30th March 2009, 23:31
  2. Linking problem on Mac os x 10.4
    By maverick_pol in forum General Programming
    Replies: 0
    Last Post: 6th January 2008, 14:09
  3. Linking problem
    By prosass in forum Newbie
    Replies: 3
    Last Post: 2nd March 2007, 12:22
  4. problem with linking
    By mickey in forum Qt Programming
    Replies: 49
    Last Post: 12th August 2006, 21:41
  5. linking problem
    By high_flyer in forum Qt Programming
    Replies: 2
    Last Post: 7th August 2006, 14:30

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.