mphowardlab / azplugins

A HOOMD-blue component for soft matter simulations.
BSD 3-Clause "New" or "Revised" License
21 stars 13 forks source link

Compiler error error: use 'template' keyword to treat 'connect' as a dependent template name in BounceBackNVE #25

Closed astatt closed 4 years ago

astatt commented 4 years ago

Internal plugin v0.9.1 (commit 0c88936a) (hoomd v2.6.0) compiled on mac with Apple clang version 11.0.0 (clang-1100.0.33.17, no cuda) results in

/Users/statt/Programs/hoomd-blue/hoomd/azplugins/BounceBackNVE.h:91:35: error: use 'template' keyword to treat 'connect' as a dependent template name
    m_pdata->getBoxChangeSignal().connect<BounceBackNVE<Geometry>, &BounceBackNVE<Geometry>::requestValidate>(this);

/Users/statt/Programs/hoomd-blue/hoomd/azplugins/BounceBackNVE.h:99:35: error: use 'template' keyword to treat 'disconnect' as a dependent template name
    m_pdata->getBoxChangeSignal().disconnect<BounceBackNVE<Geometry>, &BounceBackNVE<Geometry>::requestValidate>(this);

external plugin compiles but crashes at runtime with

  File "hist_class_test.hoomd", line 9, in <module>
    import azplugins
  File "/Users/statt/Programs/azplugins-0.7.0/azplugins/__init__.py", line 13, in <module>
    from . import _azplugins
ImportError: dlopen(/Users/statt/Programs/azplugins-0.7.0/azplugins/_azplugins.cpython-37m-darwin.so, 2): Symbol not found: __ZN24IntegrationMethodTwoStep17getRotationalNDOFESt10shared_ptrI13ParticleGroupE
  Referenced from: /Users/statt/Programs/azplugins-0.7.0/azplugins/_azplugins.cpython-37m-darwin.so
  Expected in: flat namespace
 in /Users/statt/Programs/azplugins-0.7.0/azplugins/_azplugins.cpython-37m-darwin.so

will test if this is mac specific, user error or something else.

astatt commented 4 years ago

Error can not be reproduced on Ubuntu 18.04.2 LTS with g++/gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0. Both internal and external compilation work without any problems.

On mac, the error persists also with g++/gcc-9 (Homebrew GCC 9.2.0_2) 9.2.0 and g++/gcc-7 (Homebrew GCC 7.5.0_1) 7.5.0.

mphoward commented 4 years ago

The first error is a clang-specific error, I think, related to templates within templates. The solution is to add the template keyword before connect and disconnect in BounceBackNVE.h like here:

https://github.com/glotzerlab/hoomd-blue/blob/df7970121b19bc4f8674348ab3241055ac87153b/hoomd/md/PotentialPair.h#L261-L262

I honestly don't understand the second error. It looks like a linker issue or maybe like the plugin compilation somehow failed. Could you try patching as proposed above and see if it fixes your problem? I currently don't have a clang compiler in the test container, but I could add one in the future. hoomd supports clang 5, 6, 7, and 8.

mphoward commented 4 years ago

Fixed by PR #27