openmm / openmm-plumed

OpenMM plugin to interface with PLUMED
55 stars 23 forks source link

Error loading an external library #39

Closed dlukauskis closed 3 years ago

dlukauskis commented 3 years ago

Hi,

I'm attempting to use an external C script to do funnel Metadynamics using OpenMM-PLUMED, however it it fails to load the script, with the following error:

+++ PLUMED error
+++ at PlumedMain.cpp:914, function void PLMD::PlumedMain::load(const string&)
+++ message follows +++
I cannot load library ./ProjectionOnAxis.so ./ProjectionOnAxis.so: undefined symbol: _ZTIN4PLMD6ActionE

I've compiled OpenMM from source and patched it with the PLUMED plugin from the master branch, using gcc/g++ 7.5.0. PLUMED version is 2.6.1. Amber20 loads ProjectionOnAxis.so perfectly fine, so it not plumed itself.

Attaching all the input files for replication. error_fun_metaD.zip

Also, here's what the PLUMED output should look like - correct_plumed_output.txt

peastman commented 3 years ago

It looks like you probably have some sort of a library linking problem. It's trying to load the library ProjectionOnAxis.so, but failing because that library needs to link to yet another library to find the symbol PLMD::Action. What file is that symbol defined in?

dlukauskis commented 3 years ago

If I type find . -name "Action*" in my PLUMED_ROOT, I get:

./include/plumed/colvar/ActionRegister.h
./include/plumed/gridtools/ActionWithGrid.h
./include/plumed/gridtools/ActionWithIntegral.h
./include/plumed/gridtools/ActionWithInputGrid.h
./include/plumed/bias/ActionRegister.h
./include/plumed/vesselbase/ActionWithVessel.h
./include/plumed/vesselbase/ActionWithInputVessel.h
./include/plumed/vesselbase/ActionWithAveraging.h
./include/plumed/core/ActionAnyorder.h
./include/plumed/core/ActionWithValue.h
./include/plumed/core/ActionSet.h
./include/plumed/core/ActionPilot.h
./include/plumed/core/ActionShortcut.h
./include/plumed/core/ActionWithVirtualAtom.h
./include/plumed/core/ActionAtomistic.h
./include/plumed/core/Action.h
./include/plumed/core/ActionSetup.h
./include/plumed/core/ActionRegister.h
./include/plumed/core/ActionWithArguments.h
./include/plumed/setup/ActionSetup.h
./include/plumed/function/ActionRegister.h
./include/plumed/vatom/ActionWithVirtualAtom.h
./include/plumed/vatom/ActionRegister.h
./include/plumed/multicolvar/ActionVolume.h
peastman commented 3 years ago

Those are header files. When library contains the definition of that symbol?

dlukauskis commented 3 years ago

In lines 23, 47 and 61.

#include "colvar/Colvar.h"
#include "core/ActionRegister.h"
#include "tools/Angle.h"

#include <string>
#include <cmath>

using namespace std;

namespace PLMD {
namespace colvar {

//+PLUMEDOC COLVAR PROJECTION_ON_AXIS
/*
Calculate the projection on an axis.

\par Examples

*/
//+ENDPLUMEDOC

class ProjectionOnAxis : public Colvar {
  bool pbc;

public:
  explicit ProjectionOnAxis(const ActionOptions&);
// active methods:
  virtual void calculate();
  static void registerKeywords( Keywords& keys );
};

PLUMED_REGISTER_ACTION(ProjectionOnAxis,"PROJECTION_ON_AXIS")

void ProjectionOnAxis::registerKeywords( Keywords& keys ) {
  Colvar::registerKeywords(keys);
  keys.add("atoms","AXIS_ATOMS","the atoms that define the direction of the axis of interest");
  keys.add("atoms","ATOM","the atom whose position we want to project on the axis of interest");
}

ProjectionOnAxis::ProjectionOnAxis(const ActionOptions&ao):
  PLUMED_COLVAR_INIT(ao),
  pbc(true)

The script itself is inside the zip file I've attached earlier.

peastman commented 3 years ago

That's not what I'm talking about. That's source code. The error you're getting means that it expects those symbols to be defined inside a library that it dynamically links to at runtime. You need to identify what dynamic library (its name should end in .so) those symbols are defined in. Then figure out why the dynamic linking is failing. Is it because it can't locate the library? Possibly your library path is set incorrectly. Or maybe the symbols haven't been exported, or maybe it used a different name mangling when compiling the library.

dlukauskis commented 3 years ago

I've reinstalled openmm, plumed-2.7.0-dev and the openmm-plumed plugin and the problem of loading ProjectionOnAxis.so still presists. The dev version of PLUMED contains ProjectionOnAxis.so in its own library, so I no longer need to load it externally. Funnel metadynamics with openMM-plumed seems to be working fine now.