Russian Qt Forum
Апрель 20, 2024, 01:47 *
Добро пожаловать, Гость. Пожалуйста, войдите или зарегистрируйтесь.
Вам не пришло письмо с кодом активации?

Войти
 
  Начало   Форум  WIKI (Вики)FAQ Помощь Поиск Войти Регистрация  

Страниц: [1] 2 3   Вниз
  Печать  
Автор Тема: Приложение Hello, World! для Bullet в Qt  (Прочитано 18519 раз)
8Observer8
Гость
« : Апрель 12, 2014, 13:46 »

Привет!

Использую: Qt 5.2.1 for Windows 32-bit (MinGW 4.8, OpenGL, 634 MB)

У меня не получается откомпилировать это приложение: http://bulletphysics.org/mediawiki-1.5.8/index.php/Hello_World

Компилятор ругается:



Вот что я сделал:
- через cygwin64 установил cmake
- установил bullet по инструкции: http://bulletphysics.org/mediawiki-1.5.8/index.php/Installation

Получил папку include и lib:





Подсоединил include и lib так:
Код
C++ (Qt)
QT       += core
 
QT       -= gui
 
TARGET = HelloBullet
CONFIG   += console
CONFIG   -= app_bundle
 
TEMPLATE = app
 
BULLET_LOCATION = C:/cygwin64/usr/local
INCLUDEPATH += $${BULLET_LOCATION}/include/bullet
LIBS = -L$${BULLET_LOCATION}/lib
 
SOURCES += main.cpp
 

Заранее спасибо за ответ!
Записан
kibsoft
Хакер
*****
Offline Offline

Сообщений: 625


Просмотр профиля WWW
« Ответ #1 : Апрель 12, 2014, 15:35 »

Код:
LIBS = -L$${BULLET_LOCATION}/lib
Помимо пути к либам надо задавать их имена, например:
Код:
LIBS += -L$$(FFMPEG_LIBRARY_PATH) -lavformat
Записан

http://kibsoft.ru - Download the Qt Media Encoding Library here

The apps that were written using QtMEL:
http://srecorder.com - Screen recording software
8Observer8
Гость
« Ответ #2 : Апрель 12, 2014, 16:14 »

Спасибо большое! Теперь я представляю, что надо искать. Но как узнать название библиотеки? Пытаюсь искать - результата нет.
Записан
8Observer8
Гость
« Ответ #3 : Апрель 12, 2014, 16:21 »

Попытался вот так, но по-прежнему те же ошибки:
Цитировать
LIBS += -L$${BULLET_LOCATION}/lib
LIBS += -L$${BULLET_LOCATION}/lib  -lBulletDynamics -lBulletCollision -lLinearMath
Записан
Old
Джедай : наставник для всех
*******
Offline Offline

Сообщений: 4349



Просмотр профиля
« Ответ #4 : Апрель 12, 2014, 16:32 »

Попытался вот так, но по-прежнему те же ошибки:
Цитировать
LIBS += -L$${BULLET_LOCATION}/lib
LIBS += -L$${BULLET_LOCATION}/lib  -lBulletDynamics -lBulletCollision -lLinearMath
Скажите, вы после изменения pro файла qmake не забываете запускать?
Первая строка лишняя.
Записан
8Observer8
Гость
« Ответ #5 : Апрель 12, 2014, 16:36 »

Пробовал:
- Run qmake
- Clean
- Rebuild
- даже папку Build удалял
Записан
Old
Джедай : наставник для всех
*******
Offline Offline

Сообщений: 4349



Просмотр профиля
« Ответ #6 : Апрель 12, 2014, 16:37 »

Покажите ошибки с самого начала.
Записан
8Observer8
Гость
« Ответ #7 : Апрель 12, 2014, 16:41 »

Я думаю, что надо отладочные библиотеки подключать, как в Qwt я делал для debug:
Цитировать
LIBS += -L$${QWT_LOCATION}/lib \
     -lqwtd

Но в Bullet нет библиотек с буквой 'd'. Может надо было при перед сборкой Bullet настроить.

Покажите ошибки с самого начала.



main.cpp
Код
C++ (Qt)
#include <QCoreApplication>
#include <btBulletDynamicsCommon.h>
#include <iostream>
 
int main(int argc, char *argv[])
{
   QCoreApplication a(argc, argv);
 
   btBroadphaseInterface* broadphase = new btDbvtBroadphase();
 
   btDefaultCollisionConfiguration* collisionConfiguration = new btDefaultCollisionConfiguration();
   btCollisionDispatcher* dispatcher = new btCollisionDispatcher(collisionConfiguration);
 
   btSequentialImpulseConstraintSolver* solver = new btSequentialImpulseConstraintSolver;
 
   btDiscreteDynamicsWorld* dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,broadphase,solver,collisionConfiguration);
 
   dynamicsWorld->setGravity(btVector3(0,-10,0));
 
 
   btCollisionShape* groundShape = new btStaticPlaneShape(btVector3(0,1,0),1);
 
   btCollisionShape* fallShape = new btSphereShape(1);
 
 
   btDefaultMotionState* groundMotionState = new btDefaultMotionState(btTransform(btQuaternion(0,0,0,1),btVector3(0,-1,0)));
   btRigidBody::btRigidBodyConstructionInfo
           groundRigidBodyCI(0,groundMotionState,groundShape,btVector3(0,0,0));
   btRigidBody* groundRigidBody = new btRigidBody(groundRigidBodyCI);
   dynamicsWorld->addRigidBody(groundRigidBody);
 
 
   btDefaultMotionState* fallMotionState =
           new btDefaultMotionState(btTransform(btQuaternion(0,0,0,1),btVector3(0,50,0)));
   btScalar mass = 1;
   btVector3 fallInertia(0,0,0);
   fallShape->calculateLocalInertia(mass,fallInertia);
   btRigidBody::btRigidBodyConstructionInfo fallRigidBodyCI(mass,fallMotionState,fallShape,fallInertia);
   btRigidBody* fallRigidBody = new btRigidBody(fallRigidBodyCI);
   dynamicsWorld->addRigidBody(fallRigidBody);
 
 
   for (int i=0 ; i<300 ; i++) {
       dynamicsWorld->stepSimulation(1/60.f,10);
 
       btTransform trans;
       fallRigidBody->getMotionState()->getWorldTransform(trans);
 
       std::cout << "sphere height: " << trans.getOrigin().getY() << std::endl;
   }
 
   dynamicsWorld->removeRigidBody(fallRigidBody);
   delete fallRigidBody->getMotionState();
   delete fallRigidBody;
 
   dynamicsWorld->removeRigidBody(groundRigidBody);
   delete groundRigidBody->getMotionState();
   delete groundRigidBody;
 
   delete fallShape;
   delete groundShape;
 
   delete dynamicsWorld;
   delete solver;
   delete collisionConfiguration;
   delete dispatcher;
   delete broadphase;
 
   return a.exec();
}
 
« Последнее редактирование: Апрель 12, 2014, 16:56 от 8Observer8 » Записан
Old
Джедай : наставник для всех
*******
Offline Offline

Сообщений: 4349



Просмотр профиля
« Ответ #8 : Апрель 12, 2014, 16:45 »

Покажите консоль сборки креатора, там где он команды и ошибки печатает.
И лучше просто в виде текста. Улыбающийся
Записан
8Observer8
Гость
« Ответ #9 : Апрель 12, 2014, 16:50 »

Я понял, о чём Вы. Просто у меня всегда окно "Compile Output" было скрыто. Я им не пользовался. Нашёл его в меню "Window" -> "Output Panels" -> "Compile Output"

Цитировать
17:46:53: Running steps for project HelloBullet...
17:46:53: Configuration unchanged, skipping qmake step.
17:46:53: Starting: "C:\Qt\Qt5.2.1\Tools\mingw48_32\bin\mingw32-make.exe"
C:/Qt/Qt5.2.1/Tools/mingw48_32/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory 'D:/Documents/Qt/QtBullet/build-HelloBullet-Desktop_Qt_5_2_1_MinGW_32bit-Debug'
g++ -Wl,-subsystem,console -mthreads -o debug/HelloBullet.exe debug/main.o  -LC:/cygwin64/usr/local/lib -lBulletDynamics -lBulletCollision -lLinearMath -lBulletSoftBody -LC:\Qt\Qt5.2.1\5.2.1\mingw48_32\lib -lQt5Cored
debug/main.o: In function `main':
D:\Documents\Qt\QtBullet\build-HelloBullet-Desktop_Qt_5_2_1_MinGW_32bit-Debug/../HelloBullet/main.cpp:9: undefined reference to `btDbvtBroadphase::btDbvtBroadphase(btOverlappingPairCache*)'
D:\Documents\Qt\QtBullet\build-HelloBullet-Desktop_Qt_5_2_1_MinGW_32bit-Debug/../HelloBullet/main.cpp:11: undefined reference to `btDefaultCollisionConfiguration::btDefaultCollisionConfiguration(btDefaultCollisionConstructionInfo const&)'
D:\Documents\Qt\QtBullet\build-HelloBullet-Desktop_Qt_5_2_1_MinGW_32bit-Debug/../HelloBullet/main.cpp:12: undefined reference to `btCollisionDispatcher::btCollisionDispatcher(btCollisionConfiguration*)'
D:\Documents\Qt\QtBullet\build-HelloBullet-Desktop_Qt_5_2_1_MinGW_32bit-Debug/../HelloBullet/main.cpp:14: undefined reference to `btSequentialImpulseConstraintSolver::btSequentialImpulseConstraintSolver()'
D:\Documents\Qt\QtBullet\build-HelloBullet-Desktop_Qt_5_2_1_MinGW_32bit-Debug/../HelloBullet/main.cpp:16: undefined reference to `btDiscreteDynamicsWorld::btDiscreteDynamicsWorld(btDispatcher*, btBroadphaseInterface*, btConstraintSolver*, btCollisionConfiguration*)'
D:\Documents\Qt\QtBullet\build-HelloBullet-Desktop_Qt_5_2_1_MinGW_32bit-Debug/../HelloBullet/main.cpp:21: undefined reference to `btStaticPlaneShape::btStaticPlaneShape(btVector3 const&, float)'
D:\Documents\Qt\QtBullet\build-HelloBullet-Desktop_Qt_5_2_1_MinGW_32bit-Debug/../HelloBullet/main.cpp:29: undefined reference to `btRigidBody::btRigidBody(btRigidBody::btRigidBodyConstructionInfo const&)'
D:\Documents\Qt\QtBullet\build-HelloBullet-Desktop_Qt_5_2_1_MinGW_32bit-Debug/../HelloBullet/main.cpp:39: undefined reference to `btRigidBody::btRigidBody(btRigidBody::btRigidBodyConstructionInfo const&)'
debug/main.o: In function `ZN17btCollisionObjectnwEj':
C:/cygwin64/usr/local/include/bullet/BulletCollision/CollisionDispatch/btCollisionObject.h:123: undefined reference to `btAlignedAllocInternal(unsigned int, int)'
debug/main.o: In function `ZN17btCollisionObjectdlEPv':
C:/cygwin64/usr/local/include/bullet/BulletCollision/CollisionDispatch/btCollisionObject.h:123: undefined reference to `btAlignedFreeInternal(void*)'
debug/main.o: In function `ZN13btSphereShapenwEj':
C:/cygwin64/usr/local/include/bullet/BulletCollision/CollisionShapes/btSphereShape.h:27: undefined reference to `btAlignedAllocInternal(unsigned int, int)'
debug/main.o: In function `ZN13btSphereShapedlEPv':
C:/cygwin64/usr/local/include/bullet/BulletCollision/CollisionShapes/btSphereShape.h:27: undefined reference to `btAlignedFreeInternal(void*)'
debug/main.o: In function `ZN13btSphereShapeC1Ef':
C:/cygwin64/usr/local/include/bullet/BulletCollision/CollisionShapes/btSphereShape.h:29: undefined reference to `btConvexInternalShape::btConvexInternalShape()'
C:/cygwin64/usr/local/include/bullet/BulletCollision/CollisionShapes/btSphereShape.h:29: undefined reference to `vtable for btSphereShape'
debug/main.o: In function `ZN18btStaticPlaneShapenwEj':
C:/cygwin64/usr/local/include/bullet/BulletCollision/CollisionShapes/btStaticPlaneShape.h:34: undefined reference to `btAlignedAllocInternal(unsigned int, int)'
debug/main.o: In function `ZN18btStaticPlaneShapedlEPv':
C:/cygwin64/usr/local/include/bullet/BulletCollision/CollisionShapes/btStaticPlaneShape.h:34: undefined reference to `btAlignedFreeInternal(void*)'
debug/main.o: In function `ZN20btDefaultMotionStatenwEj':
C:/cygwin64/usr/local/include/bullet/LinearMath/btDefaultMotionState.h:14: undefined reference to `btAlignedAllocInternal(unsigned int, int)'
debug/main.o: In function `ZN20btDefaultMotionStatedlEPv':
C:/cygwin64/usr/local/include/bullet/LinearMath/btDefaultMotionState.h:14: undefined reference to `btAlignedFreeInternal(void*)'
debug/main.o: In function `ZN23btDiscreteDynamicsWorldnwEj':
C:/cygwin64/usr/local/include/bullet/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h:99: undefined reference to `btAlignedAllocInternal(unsigned int, int)'
debug/main.o: In function `ZN23btDiscreteDynamicsWorlddlEPv':
C:/cygwin64/usr/local/include/bullet/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h:99: undefined reference to `btAlignedFreeInternal(void*)'
debug/main.o: In function `ZN17btTypedConstraintdlEPv':
C:/cygwin64/usr/local/include/bullet/BulletDynamics/ConstraintSolver/btTypedConstraint.h:112: undefined reference to `btAlignedFreeInternal(void*)'
debug/main.o: In function `ZN35btSequentialImpulseConstraintSolvernwEj':
C:/cygwin64/usr/local/include/bullet/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h:112: undefined reference to `btAlignedAllocInternal(unsigned int, int)'
debug/main.o: In function `ZN35btSequentialImpulseConstraintSolverdlEPv':
C:/cygwin64/usr/local/include/bullet/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h:112: undefined reference to `btAlignedFreeInternal(void*)'
debug/main.o: In function `ZN18btAlignedAllocatorIiLj16EE10deallocateEPi':
Makefile.Debug:77: recipe for target 'debug/HelloBullet.exe' failed
mingw32-make[1]: Leaving directory 'D:/Documents/Qt/QtBullet/build-HelloBullet-Desktop_Qt_5_2_1_MinGW_32bit-Debug'
makefile:34: recipe for target 'debug' failed
C:/cygwin64/usr/local/include/bullet/LinearMath/btAlignedAllocator.h:90: undefined reference to `btAlignedFreeInternal(void*)'
debug/main.o: In function `ZN18btAlignedAllocatorI9btHashIntLj16EE10deallocateEPS0_':
C:/cygwin64/usr/local/include/bullet/LinearMath/btAlignedAllocator.h:90: undefined reference to `btAlignedFreeInternal(void*)'
debug/main.o: In function `ZN18btAlignedAllocatorI14btTriangleInfoLj16EE10deallocateEPS0_':
C:/cygwin64/usr/local/include/bullet/LinearMath/btAlignedAllocator.h:90: undefined reference to `btAlignedFreeInternal(void*)'
debug/main.o:main.cpp:(.rdata$_ZTV17btTypedConstraint[__ZTV17btTypedConstraint]+0x30): undefined reference to `btTypedConstraint::serialize(void*, btSerializer*) const'
collect2.exe: error: ld returned 1 exit status
mingw32-make[1]: *** [debug/HelloBullet.exe] Error 1
mingw32-make: *** [debug] Error 2
17:46:54: The process "C:\Qt\Qt5.2.1\Tools\mingw48_32\bin\mingw32-make.exe" exited with code 2.
Error while building/deploying project HelloBullet (kit: Desktop Qt 5.2.1 MinGW 32bit)
When executing step 'Make'
17:46:54: Elapsed time: 00:01.
« Последнее редактирование: Апрель 12, 2014, 16:52 от 8Observer8 » Записан
8Observer8
Гость
« Ответ #10 : Апрель 12, 2014, 16:59 »

Получается, что там тоже самое, что и на картинке.
Записан
Old
Джедай : наставник для всех
*******
Offline Offline

Сообщений: 4349



Просмотр профиля
« Ответ #11 : Апрель 12, 2014, 17:02 »

Получается, что там тоже самое, что и на картинке.
Я на пути и на названия библиотек хотел посмотреть.

Странно как-то, или вы не все библиотеки подключили, или одно из двух.
Записан
8Observer8
Гость
« Ответ #12 : Апрель 12, 2014, 17:07 »

Подключил все, которые есть:
Записан
8Observer8
Гость
« Ответ #13 : Апрель 12, 2014, 17:11 »

Что интересно, если переключиться на Release, то ошибки всего четыре (по факту две):

Записан
Old
Джедай : наставник для всех
*******
Offline Offline

Сообщений: 4349



Просмотр профиля
« Ответ #14 : Апрель 12, 2014, 17:20 »

Вы готовые библиотеки скачивали или сами собирали. Если второе, то каким компилятором (из какой директории)?
Записан
Страниц: [1] 2 3   Вверх
  Печать  
 
Перейти в:  


Страница сгенерирована за 0.11 секунд. Запросов: 22.