Simbody体系结构x86_64的未定义符号

时间:2014-07-14 13:29:41

标签: c++ macos

我正在尝试在Mac OSX上编译simbody的示例代码。示例代码如下:

#include "Simbody.h"

using namespace SimTK;

int main() {
    // Define the system.
    MultibodySystem system;
    SimbodyMatterSubsystem matter(system);
    GeneralForceSubsystem forces(system);
    Force::Gravity gravity(forces, matter, -YAxis, 9.8);

    // Describe mass and visualization properties for a generic body.
    Body::Rigid bodyInfo(MassProperties(1.0, Vec3(0), UnitInertia(1)));
    bodyInfo.addDecoration(Transform(), DecorativeSphere(0.1));

    // Create the moving (mobilized) bodies of the pendulum.
    MobilizedBody::Pin pendulum1(matter.Ground(), Transform(Vec3(0)),
        bodyInfo, Transform(Vec3(0, 1, 0)));
    MobilizedBody::Pin pendulum2(pendulum1, Transform(Vec3(0)),
        bodyInfo, Transform(Vec3(0, 1, 0)));

    // Set up visualization.
    Visualizer viz(system);
    system.addEventReporter(new Visualizer::Reporter(viz, 0.01));

    // Initialize the system and state.
    State state = system.realizeTopology();
    pendulum2.setRate(state, 5.0);

    // Simulate for 20 seconds.
    RungeKuttaMersonIntegrator integ(system);
    TimeStepper ts(system, integ);
    ts.initialize(state);
    ts.stepTo(20.0);
}

通过自制软件安装Simbody,我使用以下命令进行编译:

c++ -o test -I /usr/local/include/simbody test.cpp(有趣的是,如果包含路径未明确声明为param,则会抱怨Simbody.h无法找到。

Undefined symbols for architecture x86_64:    
  "SimTK::Integrator::~Integrator()", referenced from:    
      SimTK::RungeKuttaMersonIntegrator::~RungeKuttaMersonIntegrator() in test-26c32c.o    
  "SimTK::Visualizer::Reporter::Reporter(SimTK::Visualizer const&, double)", referenced from:    
      _main in test-26c32c.o    
  "SimTK::Visualizer::Visualizer(SimTK::MultibodySystem const&)", referenced from:    
      _main in test-26c32c.o    
  "SimTK::Visualizer::~Visualizer()", referenced from:    
      _main in test-26c32c.o    
  "SimTK::PIMPLHandle<SimTK::MobilizedBody, SimTK::MobilizedBodyImpl, true>::~PIMPLHandle()", referenced from:    
      SimTK::MobilizedBody::~MobilizedBody() in test-26c32c.o    
  "SimTK::PIMPLHandle<SimTK::Force, SimTK::ForceImpl, true>::~PIMPLHandle()", referenced from:    
      SimTK::Force::~Force() in test-26c32c.o    
  "SimTK::TimeStepper::initialize(SimTK::State const&)", referenced from:    
      _main in test-26c32c.o    
  "SimTK::TimeStepper::stepTo(double)", referenced from:    
      _main in test-26c32c.o    
  "SimTK::TimeStepper::TimeStepper(SimTK::System const&, SimTK::Integrator&)", referenced from:    
      _main in test-26c32c.o    
  "SimTK::TimeStepper::~TimeStepper()", referenced from:    
      _main in test-26c32c.o    
  "SimTK::MobilizedBody::Pin::Pin(SimTK::MobilizedBody&, SimTK::Transform_<double> const&, SimTK::Body const&, SimTK::Transform_<double> const&, SimTK::MobilizedBody::Direction)", referenced from:    
      _main in test-26c32c.o    
  "SimTK::MultibodySystem::MultibodySystem()", referenced from:    
      _main in test-26c32c.o    
  "SimTK::SignificantReal", referenced from:    
      SimTK::Inertia_<double>::errChk(char const*) const in test-26c32c.o    
  "SimTK::DecorativeSphere::DecorativeSphere(double)", referenced from:    
      _main in test-26c32c.o    
  "SimTK::DecorativeGeometry::~DecorativeGeometry()", referenced from:    
      SimTK::DecorativeSphere::~DecorativeSphere() in test-26c32c.o    
  "SimTK::GeneralForceSubsystem::GeneralForceSubsystem(SimTK::MultibodySystem&)", referenced from:    
      _main in test-26c32c.o    
  "SimTK::SimbodyMatterSubsystem::updGround()", referenced from:    
      SimTK::SimbodyMatterSubsystem::Ground() in test-26c32c.o    
  "SimTK::SimbodyMatterSubsystem::SimbodyMatterSubsystem(SimTK::MultibodySystem&)", referenced from:    
      _main in test-26c32c.o    
  "SimTK::RungeKuttaMersonIntegrator::RungeKuttaMersonIntegrator(SimTK::System const&)", referenced from:    
      _main in test-26c32c.o    
  "SimTK::Body::addDecoration(SimTK::Transform_<double> const&, SimTK::DecorativeGeometry const&)", referenced from:    
      _main in test-26c32c.o    
  "SimTK::Body::Rigid::Rigid(SimTK::MassProperties_<double> const&)", referenced from:    
      _main in test-26c32c.o    
  "SimTK::Body::~Body()", referenced from:    
      SimTK::Body::Rigid::~Rigid() in test-26c32c.o    
  "SimTK::Force::Gravity::Gravity(SimTK::GeneralForceSubsystem&, SimTK::SimbodyMatterSubsystem const&, SimTK::UnitVec<double, 1> const&, double, double)", referenced from:    
      _main in test-26c32c.o    
  "SimTK::State::State(SimTK::State const&)", referenced from:    
      _main in test-26c32c.o    
  "SimTK::State::~State()", referenced from:    
      _main in test-26c32c.o    
  "SimTK::YAxis", referenced from:    
      _main in test-26c32c.o    
  "SimTK::System::~System()", referenced from:    
      SimTK::MultibodySystem::~MultibodySystem() in test-26c32c.o    
  "SimTK::NegYAxis", referenced from:    
      SimTK::operator-(SimTK::CoordinateAxis::YCoordinateAxis const&) in test-26c32c.o    
  "SimTK::Subsystem::~Subsystem()", referenced from:    
      SimTK::SimbodyMatterSubsystem::~SimbodyMatterSubsystem() in test-26c32c.o    
      SimTK::ForceSubsystem::~ForceSubsystem() in test-26c32c.o    
  "SimTK::MobilizedBody::Pin::setU(SimTK::State&, double) const", referenced from:    
      SimTK::MobilizedBody::Pin::setRate(SimTK::State&, double) in test-26c32c.o    
  "SimTK::DefaultSystemSubsystem::addEventReporter(SimTK::ScheduledEventReporter*) const", referenced from:    
      SimTK::System::addEventReporter(SimTK::ScheduledEventReporter*) const in test-26c32c.o    
  "SimTK::System::realizeTopology() const", referenced from:    
      _main in test-26c32c.o    
  "SimTK::System::getDefaultSubsystem() const", referenced from:    
      SimTK::System::addEventReporter(SimTK::ScheduledEventReporter*) const in test-26c32c.o    
ld: symbol(s) not found for architecture x86_64    
clang: error: linker command failed with exit code 1 (use -v to see invocation)

如何编译此代码?我需要链接哪些lib?

0 个答案:

没有答案