Undefined references when compiling tug_of_war example

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
ian williams
Posts: 4
Joined: Fri Feb 24, 2012 11:49 am

Undefined references when compiling tug_of_war example

Post by ian williams » Tue Feb 19, 2013 7:17 am

Hi,

Sorry for the noob question, but i'm having difficulty getting any simulations to compile. I'm using the opensim 3 source on ubuntu 12 with gcc (v4.7.2).

The command i'm using and the error message are shown below in the code tags. The first included folder is where simbody was installed to and the second is where i unzipped the OpenSim source to.

Does anyone have any suggestions, i'm sure the solution is simple, but its evading me... If you need anymore info just let me know!
Thanks!
Ian

Code i'm compiling:

Code: Select all

#include <OpenSim/OpenSim.h>
using namespace OpenSim; 
  
int main()
{
  try {
	// Create an OpenSim model and set its name
	Model osimModel;
	osimModel.setName("tugOfWar");

  }
  catch (OpenSim::Exception ex) {
  std::cout << ex.getMessage() << std::endl;
  return 1;
} 
  
std::cout << "OpenSim example completed successfully.\n";
return 0;
}

Compile command and errors

Code: Select all

g++ tug_of_war_2.cpp -I /usr/local/SimTK/include -I ~/Downloads/source/OpenSim-3.0.0-source -o tug 

/tmp/ccUCLs3n.o: In function `main':
tug_of_war_2.cpp:(.text+0x256): undefined reference to `OpenSim::Model::Model()'
tug_of_war_2.cpp:(.text+0x299): undefined reference to `OpenSim::Object::setName(std::string const&)'
tug_of_war_2.cpp:(.text+0x2c6): undefined reference to `OpenSim::Model::~Model()'
tug_of_war_2.cpp:(.text+0x31c): undefined reference to `OpenSim::Model::~Model()'
tug_of_war_2.cpp:(.text+0x39c): undefined reference to `OpenSim::Exception::getMessage() const'
/tmp/ccUCLs3n.o: In function `OpenSim::Exception::~Exception()':
tug_of_war_2.cpp:(.text._ZN7OpenSim9ExceptionD2Ev[_ZN7OpenSim9ExceptionD5Ev]+0x16): undefined reference to `vtable for OpenSim::Exception'
/tmp/ccUCLs3n.o:(.gcc_except_table+0x60): undefined reference to `typeinfo for OpenSim::Exception'
/tmp/ccUCLs3n.o: In function `OpenSim::Exception::Exception(OpenSim::Exception const&)':
tug_of_war_2.cpp:(.text._ZN7OpenSim9ExceptionC2ERKS0_[_ZN7OpenSim9ExceptionC5ERKS0_]+0x2b): undefined reference to `vtable for OpenSim::Exception'
/tmp/ccUCLs3n.o: In function `osimInstantiator::osimInstantiator()':
tug_of_war_2.cpp:(.text._ZN16osimInstantiatorC2Ev[_ZN16osimInstantiatorC5Ev]+0xd): undefined reference to `RegisterTypes_osimCommon'
tug_of_war_2.cpp:(.text._ZN16osimInstantiatorC2Ev[_ZN16osimInstantiatorC5Ev]+0x12): undefined reference to `RegisterTypes_osimSimulation'
tug_of_war_2.cpp:(.text._ZN16osimInstantiatorC2Ev[_ZN16osimInstantiatorC5Ev]+0x17): undefined reference to `RegisterTypes_osimActuators'
tug_of_war_2.cpp:(.text._ZN16osimInstantiatorC2Ev[_ZN16osimInstantiatorC5Ev]+0x1c): undefined reference to `RegisterTypes_osimAnalyses'
tug_of_war_2.cpp:(.text._ZN16osimInstantiatorC2Ev[_ZN16osimInstantiatorC5Ev]+0x21): undefined reference to `RegisterTypes_osimTools'
collect2: error: ld returned 1 exit status

User avatar
ian williams
Posts: 4
Joined: Fri Feb 24, 2012 11:49 am

Re: Undefined references when compiling tug_of_war example

Post by ian williams » Tue Feb 19, 2013 8:46 am

Doh, completely forgot i need to use cmake and link in the object files

POST REPLY