openmm / openmm-plumed

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

building error #16

Closed Zhou-Yang closed 6 years ago

Zhou-Yang commented 6 years ago

Hi, When I try to build this plugin, I got this:

Scanning dependencies of target OpenMMPlumed
[  5%] Building CXX object CMakeFiles/OpenMMPlumed.dir/openmmapi/src/PlumedForce.cpp.o
/home/zy/proj/link_to_2T/software/openmm-plumed/openmmapi/src/PlumedForce.cpp: In member function ‘virtual OpenMM::ForceImpl* PlumedPlugin::PlumedForce::cre:
/home/zy/proj/link_to_2T/software/openmm-plumed/openmmapi/src/PlumedForce.cpp:47:37: error: invalid new-expression of abstract class type ‘PlumedPlugin::Plu’
     return new PlumedForceImpl(*this);
                                     ^
In file included from /home/zy/proj/link_to_2T/software/openmm-plumed/openmmapi/src/PlumedForce.cpp:33:0:
/home/zy/proj/link_to_2T/software/openmm-plumed/openmmapi/include/internal/PlumedForceImpl.h:50:28: note:   because the following virtual functions are pure:
 class OPENMM_EXPORT_PLUMED PlumedForceImpl : public OpenMM::ForceImpl {
                            ^
In file included from /home/zy/proj/link_to_2T/software/openmm-plumed/openmmapi/include/internal/PlumedForceImpl.h:36:0,
                 from /home/zy/proj/link_to_2T/software/openmm-plumed/openmmapi/src/PlumedForce.cpp:33:
/home/zy/anaconda2/pkgs/openmm-7.1.1-py36_0/include/openmm/internal/ForceImpl.h:77:18: note:    virtual void OpenMM::ForceImpl::updateContextState(OpenMM::C)
     virtual void updateContextState(ContextImpl& context) = 0;
                  ^
CMakeFiles/OpenMMPlumed.dir/build.make:62: recipe for target 'CMakeFiles/OpenMMPlumed.dir/openmmapi/src/PlumedForce.cpp.o' failed
make[2]: *** [CMakeFiles/OpenMMPlumed.dir/openmmapi/src/PlumedForce.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/OpenMMPlumed.dir/all' failed
make[1]: *** [CMakeFiles/OpenMMPlumed.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2

and the cmake setting: qq 20180424194708

Could you help look is there anything wrong?

peastman commented 6 years ago

You need to build against OpenMM 7.2 or later, since the signature of that function changed. You're building against 7.1.1.

Zhou-Yang commented 6 years ago

changed to OpenMM 7.2.1

cmake .. \
cmake .. \
-DCMAKE_BUILD_TYPE=0 \
-DCMAKE_INSTALL_PREFIX=/home/zy/anaconda2/pkgs/openmm-7.2.1-py36_1 \
-DCUDA_HOST_COMPILER=/usr/bin/cc \
-DCUDA_SDK_ROOT_DIR=/home/zy/NVIDIA_CUDA-8.0_Samples \
-DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-8.0 \
-DCUDA_rt_LIBRARY=/usr/lib/x86_64-linux-gnu/librt.so \
-DOPENMM_DIR=/home/zy/anaconda2/pkgs/openmm-7.2.1-py36_1 \
-DPLUMED_BUILD_CUDA_LIB=1 \
-DPLUMED_INCLUDE_DIR=/home/zy/anaconda2/envs/py36/include/plumed \
-DPLUMED_LIBRARY_DIR=/home/zy/anaconda2/envs/py36/lib/plumed \
-DPYTHON_EXECUTABLE=/home/zy/anaconda2/envs/py36/bin/python

got:

[ 36%] Linking CXX executable TestSerializePlumedForce
CMakeFiles/TestSerializePlumedForce.dir/TestSerializePlumedForce.cpp.o: In function `testSerialization()':
TestSerializePlumedForce.cpp:(.text+0x1b6): undefined reference to `OpenMM::throwException(char const*, int, std::__cxx11::basic_string<char, std::char_traits<char>, s'
CMakeFiles/TestSerializePlumedForce.dir/TestSerializePlumedForce.cpp.o: In function `void OpenMM::XmlSerializer::serialize<PlumedPlugin::PlumedForce>(PlumedPlugin::Plu:
TestSerializePlumedForce.cpp:(.text._ZN6OpenMM13XmlSerializer9serializeIN12PlumedPlugin11PlumedForceEEEvPKT_RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSo[_'
TestSerializePlumedForce.cpp:(.text._ZN6OpenMM13XmlSerializer9serializeIN12PlumedPlugin11PlumedForceEEEvPKT_RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSo[_'
TestSerializePlumedForce.cpp:(.text._ZN6OpenMM13XmlSerializer9serializeIN12PlumedPlugin11PlumedForceEEEvPKT_RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSo[_'
TestSerializePlumedForce.cpp:(.text._ZN6OpenMM13XmlSerializer9serializeIN12PlumedPlugin11PlumedForceEEEvPKT_RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSo[_'
TestSerializePlumedForce.cpp:(.text._ZN6OpenMM13XmlSerializer9serializeIN12PlumedPlugin11PlumedForceEEEvPKT_RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSo[_'
../../libOpenMMPlumed.so: undefined reference to `OpenMM::Platform::createKernel(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&'
../../libOpenMMPlumed.so: undefined reference to `OpenMM::SerializationNode::getIntProperty(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<cha'
../../libOpenMMPlumed.so: undefined reference to `OpenMM::SerializationNode::getStringProperty(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<'
../../libOpenMMPlumed.so: undefined reference to `OpenMM::SerializationNode::setIntProperty(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<cha'
../../libOpenMMPlumed.so: undefined reference to `OpenMM::SerializationProxy::SerializationProxy(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocato'
collect2: error:ld return 1
serialization/tests/CMakeFiles/TestSerializePlumedForce.dir/build.make:95: recipe for target 'serialization/tests/TestSerializePlumedForce' failed
make[2]: *** [serialization/tests/TestSerializePlumedForce] Error 1
CMakeFiles/Makefile2:122: recipe for target 'serialization/tests/CMakeFiles/TestSerializePlumedForce.dir/all' failed
make[1]: *** [serialization/tests/CMakeFiles/TestSerializePlumedForce.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
peastman commented 6 years ago

You're running into the GCC ABI change: https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html. It looks like you're compiling the plugin with a different ABI choice than what OpenMM was compiled with. Did you compile OpenMM from source, or install it with conda?

Zhou-Yang commented 6 years ago

I installed it with conda. ok it works after add "-D_GLIBCXX_USE_CXX11_ABI=0"

looks close to success...

[100%] Linking CXX executable TestCudaPlumedForce
/usr/bin/ld: warning: libcufft.so.9.0, needed by /home/zy/anaconda2/pkgs/openmm-7.2.1-py36_1/lib/plugins/libOpenMMCUDA.so, not found (try using -rpath or -rpath-link)
/home/zy/anaconda2/pkgs/openmm-7.2.1-py36_1/lib/plugins/libOpenMMCUDA.so: undefined reference to `cufftGetVersion@libcufft.so.9.0'
/home/zy/anaconda2/pkgs/openmm-7.2.1-py36_1/lib/plugins/libOpenMMCUDA.so: undefined reference to `cufftPlan3d@libcufft.so.9.0'
/home/zy/anaconda2/pkgs/openmm-7.2.1-py36_1/lib/plugins/libOpenMMCUDA.so: undefined reference to `cufftExecD2Z@libcufft.so.9.0'
/home/zy/anaconda2/pkgs/openmm-7.2.1-py36_1/lib/plugins/libOpenMMCUDA.so: undefined reference to `cufftExecR2C@libcufft.so.9.0'
/home/zy/anaconda2/pkgs/openmm-7.2.1-py36_1/lib/plugins/libOpenMMCUDA.so: undefined reference to `cufftExecZ2D@libcufft.so.9.0'
/home/zy/anaconda2/pkgs/openmm-7.2.1-py36_1/lib/plugins/libOpenMMCUDA.so: undefined reference to `cufftDestroy@libcufft.so.9.0'
/home/zy/anaconda2/pkgs/openmm-7.2.1-py36_1/lib/plugins/libOpenMMCUDA.so: undefined reference to `cufftExecC2R@libcufft.so.9.0'
/home/zy/anaconda2/pkgs/openmm-7.2.1-py36_1/lib/plugins/libOpenMMCUDA.so: undefined reference to `cufftSetStream@libcufft.so.9.0'
collect2: error:ld return 1
platforms/cuda/tests/CMakeFiles/TestCudaPlumedForce.dir/build.make:98: recipe for target 'platforms/cuda/tests/TestCudaPlumedForce' failed
make[2]: *** [platforms/cuda/tests/TestCudaPlumedForce] Error 1
CMakeFiles/Makefile2:348: recipe for target 'platforms/cuda/tests/CMakeFiles/TestCudaPlumedForce.dir/all' failed
make[1]: *** [platforms/cuda/tests/CMakeFiles/TestCudaPlumedForce.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2

so I will need libcufft.so.9.0 ?

peastman commented 6 years ago

Since you closed this, I assume you figured it out? libcufft is part of the CUDA SDK, which you need to have installed to compile the CUDA platform.

ljmartin commented 6 years ago

@Zhou-Yang I have run into the same error during compilation (conda install also). Where do you add the "-D_GLIBCXX_USE_CXX11_ABI=0" flag?

ljmartin commented 6 years ago

@peastman do you know if this flag should be added to cmake via "Add Entry" or to the makefile? Adding a 'bool' entry in the cmake gui of either -D_GLIBCXX_USE_CXX11_ABI or GLIBCXX_USE_CXX11_ABI hasn't progressed past this linking error.

For the Makefile option, I can't see a 'cxxflags' term anywhere. The relevant part of the Makefile looks like this:

# Target rules for targets named TestSerializePlumedForce                                                  

# Build rule for target.                                                                                   
TestSerializePlumedForce: cmake_check_build_system
        $(MAKE) -f CMakeFiles/Makefile2 TestSerializePlumedForce
.PHONY : TestSerializePlumedForce

# fast build rule for target.                                                                              
TestSerializePlumedForce/fast:
        $(MAKE) -f serialization/tests/CMakeFiles/TestSerializePlumedForce.dir/build.make serialization/te\
sts/CMakeFiles/TestSerializePlumedForce.dir/build
.PHONY : TestSerializePlumedForce/fast
peastman commented 6 years ago

In the CMake GUI you should append that flag to the end of CMAKE_CXX_FLAGS_RELEASE (assuming you have CMAKE_BUILD_TYPE set to "Release").

ljmartin commented 6 years ago

Thanks! I just saw this post @peastman, but seconds before figured it out by trial and error. For those in a similar situation, I fixed it in the file 'CMakeCache.txt', where there is a line:

//Flags used by the compiler during all build types.
CMAKE_CXX_FLAGS:STRING=0

the flag goes here like so:

//Flags used by the compiler during all build types.
CMAKE_CXX_FLAGS:STRING=-D_GLIBCXX_USE_CXX11_ABI=0