1

I am a beginner to organizing C++ projects and I have been trying to start an Open Dynamics Engine project for a week now but I keep getting several errors. First, what I have done:

  • Installed ode-0.13.1 with automake as directed in the manual.
  • Created a file test.cpp with the code from the bouncing ball HOWTO.
  • Wrote a makefile to compile.

But when I run my makefile, I get the following errors:

gcc -Wall -g -DdDOUBLE -o test test.o -L/home/username/ode-0.13.1/ode/src/libode.la -L/home/username/ode-0.13.1/drawstuff/src/libdrawstuff.la -L/usr/X11R6/lib -L/usr/lib -L/usr/local/lib -I. -I/home/username/ode-0.13.1/include/ -I/usr/X11R6/include -I/usr/include -lm -lode -lGL -lGLU /usr/local/lib/libode.a(collision_trimesh_box.o): In function dCalcVectorLength3': /home/username/ode-0.13.1/ode/src/../../include/ode/odemath.h:148: undefined reference tosqrt' /home/username/ode-0.13.1/ode/src/../../include/ode/odemath.h:148: undefined reference to sqrt' /home/username/ode-0.13.1/ode/src/../../include/ode/odemath.h:148: undefined reference tosqrt' /usr/local/lib/libode.a(util.o): In function dxStepBody(dxBody*, double)': /home/username/ode-0.13.1/ode/src/util.cpp:618: undefined reference tosincos' /home/username/ode-0.13.1/ode/src/util.cpp:630: undefined reference to sincos' /home/username/ode-0.13.1/ode/src/util.cpp:628: undefined reference tosqrt' /home/username/ode-0.13.1/ode/src/util.cpp:590: undefined reference to `sqrt'

... (and this keeps going for pages)

/usr/local/lib/libode.a(OPC_AABBTree.o): In function Opcode::AABBTree::Build(Opcode::AABBTreeBuilder*)': /home/username/ode-0.13.1/OPCODE/OPC_AABBTree.cpp:413: undefined reference tooperator new[](unsigned long)' /home/username/ode-0.13.1/OPCODE/OPC_AABBTree.cpp:427: undefined reference to operator new[](unsigned long)' /usr/local/lib/libode.a(OPC_AABBTree.o): In functionOpcode::AABBTreeNode::~AABBTreeNode()': /home/username/ode-0.13.1/OPCODE/OPC_AABBTree.cpp:83: undefined reference to operator delete[](void*, unsigned long)' /usr/local/lib/libode.a(OPC_Collider.o): In functionOpcode::Collider::~Collider()': /home/username/ode-0.13.1/OPCODE/OPC_Collider.cpp:54: undefined reference to operator delete(void*, unsigned long)' /usr/local/lib/libode.a(OPC_Collider.o):(.data.rel.ro._ZTIN6Opcode8ColliderE[_ZTIN6Opcode8ColliderE]+0x0): undefined reference tovtable for __cxxabiv1::__class_type_info' /usr/local/lib/libode.a(OPC_Collider.o):(.data.rel.ro._ZTVN6Opcode8ColliderE[_ZTVN6Opcode8ColliderE]+0x20): undefined reference to `__cxa_pure_virtual' collect2: error: ld returned 1 exit status makefile:14: recipe for target 'test' failed make: *** [test] Error 1

These errors seem like the library has not been set up correctly, but I'm pretty sure I've properly installed and my -L's are set to the correct paths.

Note 1: the demos included with the ode library work.

Note 2: I've tried (and failed) to install other versions of ode previously. I did my best with make uninstall and make clean to clean these failed installs, but I think they may be affecting new installs because when I run sudo make install for the first time there is an awful lot of Nothing to do here... messages.

  • 2
    Try putting `-lm` last. `-lode -lGL -lGLU -lm`. Order matters. – john Mar 20 '19 at 23:58
  • 2
    Also use g++ not gcc for C++ code. – john Mar 20 '19 at 23:59
  • FYI it's pretty typical to install custom libs of yours into the `/usr/local` prefix (run `configure` with `--prefix=/usr/local`) so that your installs are cleanly overlaid on top of anything that your OS installed (and can be cleanly destroyed in the event that you want to delete everything you manually installed without adversely affecting your OS) – jcarpenter2 Mar 21 '19 at 01:32

0 Answers0