accessing calcPotentialEnergy
Posted: Wed Jan 21, 2015 3:45 am
Hi Sherm,
I have another question. I'm trying to access this function:
Real calcPotentialEnergy(const State& state) const;
.. which is defined in DuMMForceFieldSubsystemRep.h . A private implemention, of course, which I don't fully understand. At any rate, I tried to declare it as a member of DuMMForceFieldSubsystem , in DuMMForceFieldSubsystem.h :
316 public:
317
318 // was private, SCF made public:
319 class DuMMForceFieldSubsystemRep& updRep();
320 const DuMMForceFieldSubsystemRep& getRep() const;
321 Real calcPotentialEnergy(const State& state) const;
322 //
323
Molmodel then compiles without any problem. However when I then try to access this method in MMB:
double mdPotentialEnergy = dumm.calcPotentialEnergy(state);
I get a link error:
Linking CXX shared library libMMBlib.dylib
Undefined symbols for architecture x86_64:
"SimTK::DuMMForceFieldSubsystem::calcPotentialEnergy(SimTK::State const&) const", referenced from:
SimTK::PeriodicPdbAndEnergyWriter::handleEvent(SimTK::State&, double, bool&) const in Repel.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [libMMBlib.dylib] Error 1
make[1]: *** [CMakeFiles/MMBlib.dir/all] Error 2
make: *** [all] Error 2
I've verified that MMB is looking at the right libSimTKmolmodel.dylib
What am I doing wrong? Is there some other way to access calcPotentialEnergy without modifying the molmodel code? Or is there a cleaner way to make an accessor function?
Sam
I have another question. I'm trying to access this function:
Real calcPotentialEnergy(const State& state) const;
.. which is defined in DuMMForceFieldSubsystemRep.h . A private implemention, of course, which I don't fully understand. At any rate, I tried to declare it as a member of DuMMForceFieldSubsystem , in DuMMForceFieldSubsystem.h :
316 public:
317
318 // was private, SCF made public:
319 class DuMMForceFieldSubsystemRep& updRep();
320 const DuMMForceFieldSubsystemRep& getRep() const;
321 Real calcPotentialEnergy(const State& state) const;
322 //
323
Molmodel then compiles without any problem. However when I then try to access this method in MMB:
double mdPotentialEnergy = dumm.calcPotentialEnergy(state);
I get a link error:
Linking CXX shared library libMMBlib.dylib
Undefined symbols for architecture x86_64:
"SimTK::DuMMForceFieldSubsystem::calcPotentialEnergy(SimTK::State const&) const", referenced from:
SimTK::PeriodicPdbAndEnergyWriter::handleEvent(SimTK::State&, double, bool&) const in Repel.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [libMMBlib.dylib] Error 1
make[1]: *** [CMakeFiles/MMBlib.dir/all] Error 2
make: *** [all] Error 2
I've verified that MMB is looking at the right libSimTKmolmodel.dylib
What am I doing wrong? Is there some other way to access calcPotentialEnergy without modifying the molmodel code? Or is there a cleaner way to make an accessor function?
Sam