Problem while running Box 2d
Hello All ,
i had seen an example at http://labs.qt.nokia.com/2010/02/26/qt-box2d-is-easy/
it seems good., but the thing is should i include all the header and cpp files to my project it seems time consuming .,
m just out of ma mind how to compile my project ., just a hello world project in box 2d., will anyone hwlp me step by step how to getting start.,
i am new to Qt and Box2d.
please help me out.
What is your exact problem? You do not need to add the Box2D files to your project, it is an external library. It seems to me like you can build it with CMake.
well i dnno what is CMake and how to use it., and i had download box2d files which contain headers and cpp files nt able to find any library..
well what to do after use this CMake s/w?
I would advise you follow the suggestion packaged together with the sources. "On how to add libraries in Qt Creator":http://doc.qt.nokia.com/qtcreator-2.2/creator-project-qmake-libraries.html
not i installed the CMake s/w and trying to execute my box-2d code., but which configuration shpuld be used? m using windows-7
Have you built Box2D according to the instructions in the source package?
these are the instructions., but its for visual studio and unix., cant find for Qt for windows.
Box2D uses CMake to describe the build in a platform independent manner.
First download and install cmake from cmake.org
For Microsoft Visual Studio:
- Run the cmake-gui
- Set the source directory to the path of Box2D on your PC (the folder that contains this file).
- Set the build directory to be the path of Box2D/Build on your PC.
- Press the Configure button and select your version of Visual Studio.
- You may have to press the Configure button again.
- Press the Generate button.
- Open Box2D/Build/Box2D.sln.
- Set the Testbed or HelloWorld as your startup project.
- Press F5 or Ctrl-F5 to run.
For Unix platforms, say the following on a terminal: (Replace $BOX2DPATH with the directory where this file is located.)
cmake -DBOX2D_INSTALL=ON -DBOX2D_BUILD_SHARED=ON ..
You might want to add -DCMAKE_INSTALL_PREFIX=/opt/Box2D or similar to the cmake call to change the installation location. make install might need sudo.
Well on windows you have the chance to use either visual studio or MinGW in which case you need to follow the instructions for unix, replacing make with mingw32-make (either use the complete path or have it in your PATH environment variable)
actually box 2d already have a cmake file., but i want to know how to build it for Qt .
i use visual studio 10 version to cmake box2d code., but unable to generate cmake file.,
i think there is no other better way just to use existing cmake file.,
so atlast i have a previous cmake file., thn how to use this?
I believe you have everything you need, if you just follow the instructions in the original blog post.
actually the code provided in the original post is for linux., and i am working on windows. thats what the problem is., and i dnno how to make it work in windows..
Now we're getting closer to the problem. What exactly is the error you get when trying to build it on windows?
well the file he just contain a pro and a main.cpp file.,
.pro file contains
SOURCES += main.cpp
INCLUDEPATH += /home/ahanssen/Box2D_v2.0.1/Box2D/Include
LIBPATH += /home/ahanssen/Box2D_v2.0.1/Box2D/Source/Gen/float
LIBS += -lbox2d
and i think the include path and the lib path create error for me. coz in windows path not start with '/' (root.), and even i am unable to find "include" folder in my box2d directory as mentioned in INCLUDEPATH+= .../Include
and the error i got while compiling is :
box2d.h no such file or directory , bodydef was not declared ....... etc.... etc
You have to adjust the paths of course. The include folder will be created when you build the library.
i had made a change and copy my box2d folder in my working folder.,
SOURCES += main.cpp
INCLUDEPATH += $$PWD/Box2D_v2.0.1/Box2D/Include
LIBPATH += $$PWD/Box2D_v2.0.1/Box2D/Source/Gen/float
LIBS += -lbox2d
but the problem still occures..