SOLVED: box2d compiler error

Previous topic - Next topic


Hi all,
When I try the box2d example (I think it´s schranz0r´s) it works fine. When I add funtions/files to the project I made before I get this:
Code (glbasic) Select

IncrediBuild skips: Box2D.gbas, q_core.gbas, q_static.gbas, q_motion.gbas, q_update.gbas, q_hittest.gbas, q_layers.gbas, q_text.gbas, q_zorder.gbas,

gpc_temp9.o:gpc_temp9.cpp:(.text+0x0): multiple definition of `__GLBASIC__::Q_SwapObjectOrder(double, double)'
gpc_temp3.o:gpc_temp3.cpp:(.text+0x0): first defined here
gpc_temp9.o:gpc_temp9.cpp:(.text+0x9f0): multiple definition of `__GLBASIC__::Q_SwapLayerOrder(double, double)'
gpc_temp3.o:gpc_temp3.cpp:(.text+0x9f0): first defined here
gpc_temp0.o:gpc_temp0.cpp:(.text+0x1ab7): undefined reference to `__GLBASIC__::b_InitWorld(double, double, double, double, double, double, double)'
*** FATAL ERROR - Bitte die Compiler-Ausgabe ins Forum kopieren

It seems like the scope of the box2d variables is reaching my local in-function variables somehow. Any idea how to stop that without having to change all the names???


HI, monono, are running the example code?¿. if is not, make sure you have a Array whit 2 dimensions, I think is a polysprite(don´t remenber well now), without the array appeara an error, I´m not sure if can be this your trouble.

Make sure too, to have the libraries and the correct headers, well I put this code, don´t have sense because don´t use physics, and you only can see a asterick running to the left whit full speed, but the code have parameters and commands from box2d, if you don´t have troubles whit this code, you are making some wrong on your code or don´t have the needed files.

Best Regards,
Iván J.

PS: The file is attached in .rar

[attachment deleted by admin]


Thanks for your reply!
But I just added some of my files to the example Project. I didn´t change anything int the mainfile, and I know that these files compile fine. Pretty sure it´s something about the scope of box2d variables.
After renaming all variables, it says:
Code (glbasic) Select

gpc_temp1.o:gpc_temp1.cpp:(.text+0x1665e): undefined reference to `b2PrismaticJoint::GetJointTranslation() const'
gpc_temp1.o:gpc_temp1.cpp:(.text+0x16785): undefined reference to `b2PrismaticJoint::GetJointTranslation() const'
gpc_temp1.o:gpc_temp1.cpp:(.text+0x1686e): undefined reference to `b2PrismaticJoint::GetJointTranslation() const'
gpc_temp1.o:gpc_temp1.cpp:(.text+0x16995): undefined reference to `b2PrismaticJoint::GetJointTranslation() const'
gpc_temp1.o:gpc_temp1.cpp:(.text+0x1712a): undefined reference to `b2PrismaticJoint::GetJointTranslation() const'
gpc_temp1.o:gpc_temp1.cpp:(.text+0x1714d): more undefined references to `b2PrismaticJoint::GetJointTranslation() const' follow
gpc_temp1.o:gpc_temp1.cpp:(.text+0x17816): undefined reference to `b2PrismaticJoint::b2PrismaticJoint(b2PrismaticJointDef const*)'
*** FATAL ERROR - Bitte die Compiler-Ausgabe ins Forum kopieren

I have not a clue.


HI, monono, if you want can make a thing...
If you want put your code, or the part of code can show us, and I try to compile in my computer, for watch what´s happens.

I´m not have very hard troubles whit Box2D, I only use the example code, and over this, I use how a template.

I show you my folder configuration, of a project with box2d, perhaps, can be usefull for show or perhaps you missing or forget something in your project.

Well a folish suggestion, is, you put the library .gbal added to your porject?¿.  :-[

[attachment deleted by admin]


Thanks for your effort mentalthink! :good:
I found the mistake. As I first had the variable problem I exluded the cpp files one by one to locate the problem. In the end it was a variable called "dummy" in my functions. It even changed the color after including box2d. Then I forgot to put "#include "Source/Dynamics/Joints/b2PrismaticJoint.cpp"" back in place. That was the second compiler error. My fault!! World be aware! Physics game to come!


well, I´m happy you resolve the trouble.  :booze:

If you find the mode of make an sprite collision whit physics, I will be very happy, I has think in a mode, and works, in another post is the mode of make, when collisioning 2 sprites, the player and another, this bouces, but I don´t try for have sliding over the sprite (NO player).

I need some sprite Physics what sliding over sprites, whit no uniform shape.

Have good physics.  :good:

Best Regards,
Ivñan J.


Sry, I didn´t knew you posted. I would love to help you, but I am not a box2d specialist yet. And I cannot to understand your last post completely.