SSAGESproject / SSAGES

Software Suite for Advanced General Ensemble Simulations
GNU General Public License v3.0
81 stars 28 forks source link

Build error #5

Closed yurivict closed 5 years ago

yurivict commented 5 years ago

Errors with clang-6 compiler:

/usr/ports/science/ssages/work/SSAGES-public-0.8.3-alpha/src/CVs/CollectiveVariable.h:52:25: error: implicit instantiation of undefined template 'std::__1::array<double, 2>'
                std::array<double, 2> bounds_;          
                                      ^
/usr/include/c++/v1/__tuple:223:64: note: template is declared here
template <class _Tp, size_t _Size> struct _LIBCPP_TEMPLATE_VIS array;
                                                               ^
/usr/ports/science/ssages/work/SSAGES-public-0.8.3-alpha/src/CVs/CollectiveVariable.cpp:47:11: error: cannot initialize return object of type 'SSAGES::CollectiveVariable *' with an rvalue of type 'SSAGES::AngleCV *'
                        return AngleCV::Build(json, path);
                               ^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/ports/science/ssages/work/SSAGES-public-0.8.3-alpha/src/CVs/CollectiveVariable.cpp:49:11: error: cannot initialize return object of type 'SSAGES::CollectiveVariable *' with an rvalue of type 'SSAGES::BoxVolumeCV *'
                        return BoxVolumeCV::Build(json, path);
                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/ports/science/ssages/work/SSAGES-public-0.8.3-alpha/src/CVs/CollectiveVariable.cpp:51:11: error: cannot initialize return object of type 'SSAGES::CollectiveVariable *' with an rvalue of type 'SSAGES::GyrationTensorCV *'
                        return GyrationTensorCV::Build(json, path);
                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/ports/science/ssages/work/SSAGES-public-0.8.3-alpha/src/CVs/CollectiveVariable.cpp:53:11: error: cannot initialize return object of type 'SSAGES::CollectiveVariable *' with an rvalue of type 'SSAGES::PairwiseCV *'
                        return PairwiseCV::Build(json, path);
                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/ports/science/ssages/work/SSAGES-public-0.8.3-alpha/src/CVs/CollectiveVariable.cpp:55:11: error: cannot initialize return object of type 'SSAGES::CollectiveVariable *' with an rvalue of type 'SSAGES::ParticleCoordinateCV *'
                        return ParticleCoordinateCV::Build(json, path);
                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/ports/science/ssages/work/SSAGES-public-0.8.3-alpha/src/CVs/CollectiveVariable.cpp:57:11: error: cannot initialize return object of type 'SSAGES::CollectiveVariable *' with an rvalue of type 'SSAGES::ParticlePositionCV *'
                        return ParticlePositionCV::Build(json, path);
                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/ports/science/ssages/work/SSAGES-public-0.8.3-alpha/src/CVs/CollectiveVariable.cpp:59:11: error: cannot initialize return object of type 'SSAGES::CollectiveVariable *' with an rvalue of type 'SSAGES::ParticleSeparationCV *'
                        return ParticleSeparationCV::Build(json, path);
                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/ports/science/ssages/work/SSAGES-public-0.8.3-alpha/src/CVs/CollectiveVariable.cpp:61:11: error: cannot initialize return object of type 'SSAGES::CollectiveVariable *' with an rvalue of type 'SSAGES::RouseModeCV *'
                        return RouseModeCV::Build(json, path);
                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/ports/science/ssages/work/SSAGES-public-0.8.3-alpha/src/CVs/CollectiveVariable.cpp:63:11: error: cannot initialize return object of type 'SSAGES::CollectiveVariable *' with an rvalue of type 'SSAGES::TorsionalCV *'
                        return TorsionalCV::Build(json, path);
                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/ports/science/ssages/work/SSAGES-public-0.8.3-alpha/src/CVs/CollectiveVariable.cpp:65:11: error: cannot initialize return object of type 'SSAGES::CollectiveVariable *' with an rvalue of type 'SSAGES::AlphaRMSDCV *'
                        return AlphaRMSDCV::Build(json, path);
                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/ports/science/ssages/work/SSAGES-public-0.8.3-alpha/src/CVs/CollectiveVariable.cpp:67:11: error: cannot initialize return object of type 'SSAGES::CollectiveVariable *' with an rvalue of type 'SSAGES::ParallelBetaRMSDCV *'
                        return ParallelBetaRMSDCV::Build(json, path);
                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/ports/science/ssages/work/SSAGES-public-0.8.3-alpha/src/CVs/CollectiveVariable.cpp:69:11: error: cannot initialize return object of type 'SSAGES::CollectiveVariable *' with an rvalue of type 'SSAGES::AntiBetaRMSDCV *'
                        return AntiBetaRMSDCV::Build(json, path);
                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mquevill commented 5 years ago

I was able to perform a successful build of SSAGES v0.8.3 and LAMMPS 22 Aug 2018 with Clang 6.0. There are warnings that are output from the LAMMPS compilation, but it should still complete successfully. There could be a chance that the engine used may affect this compilation. Which engine were you trying to compile with SSAGES?

I ran

mkdir build
cd build/
cmake .. -DLAMMPS_SRC=../lammps22Aug2018 -DCMAKE_C_COMPILER=clang-6.0 -DCMAKE_CXX_COMPILER=clang++-6.0
make -j4

If you had performed a previous build and CMake is trying to reuse those files, you may get conflicts that cause the above issues. To clean your build directory, you can either delete the folder completely or run

make clean
make

to do a clean build.

If you cloned the GitHub repository, you can see if the source files have changed somehow. Run

git status

If any files in the src/ directory have been changed, you may want to checkout those files again to ensure the source isn't modified.

If the problems still exist, please show what errors/warnings you are still getting.

yurivict commented 5 years ago

This is the same what I do, and it fails with LAMMPS_SRC. The last error:

/usr/ports/science/ssages/work/SSAGES-public-0.8.3-alpha/src/CVs/CollectiveVariable.cpp:69:11: error: cannot initialize return object of type 'SSAGES::CollectiveVariable *' with an rvalue of type 'SSAGES::AntiBetaRMSDCV *'
                        return AntiBetaRMSDCV::Build(json, path);
                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
hsidky commented 5 years ago

The first error can be solved by adding #include <array> in CollectiveVariable.h. You have a pedantic compiler.

The remaining can be solved by replacing the return statements in CollectiveVariable.cpp with an explicit static cast. For example return AntiBetaRMSDCV::Build(json, path); becomes return static_cast<CollectiveVariable*>(AntiBetaRMSDCV::Build(json, path));. Clang can be quite strict about implicit type conversions. These should be fixed in the next release

If you can make those changes manually and report back, that would be great. Apologies for the inconvenience.

yurivict commented 5 years ago

Fixing the array include problem allows the build to proceed. However, now it fails in the lammps code. It insists on running BSD make (/usr/bin/make) instead of GNU make (gmake). I already have lammps installed. Is there a way to just use the existing lammps package? Also, the same situation is with gromacs, it would be better to use the pre-installed package.

hsidky commented 5 years ago

Can you reproduce the entire compilation error and details of your platform?

The issue with using an existing installation is that SSAGES (and all other advanced sampling libraries) need include additional calls/plugins in the original code in order to bias a simulation. This makes it necessary to recompile the code.

yurivict commented 5 years ago

Can you reproduce the entire compilation error and details of your platform?

The second error somehow went away once I've added the array include.

SSAGES (and all other advanced sampling libraries) need include additional calls/plugins in the original code in order to bias a simulation. This makes it necessary to recompile the code.

Does this mean that there are optional lammps plugins that aren't built by default? I would rather update the lammps package and add those to build by default.

hsidky commented 5 years ago

You mentioned it failed somewhere else, correct? Can you reproduce that error?

SSAGES contains its own lammps plugin and fix which it adds when it compiled lammps. However, there are some added complexities that means you cannot just add the plugin and compile lammps regularly. It must be compiled through SSAGES.

However, we can definitely try to resolve your build problems if you share more information on what is going on.

yurivict commented 5 years ago

With lammps, it insists on using /usr/bin/make which is a BSD make. How to override this? Adding the right make to the PATH doesn't help.

hsidky commented 5 years ago

You can try setting -DCMAKE_MAKE_PROGRAM to gmake.

mquevill commented 5 years ago

After adding #include <array> and setting -DCMAKE_MAKE_PROGRAM=gmake, were you able to compile SSAGES?

If not, please let us know what issues you are still having, as well as the compilation options you are using.

fgygi commented 4 years ago

I find the same problem when building 0.8.5-alpha on macOS using clang 10.0.1. The problem is indeed solved by adding #include <array> in CollectiveVariable.h as noted by @hsidky above. I would suggest including that simple fix.

index bc537a2..ea6ef54 100644
--- a/src/CVs/CollectiveVariable.h
+++ b/src/CVs/CollectiveVariable.h
@@ -24,6 +24,7 @@
 #include "types.h"
 #include <vector>
 #include <map>
+#include <array>

 // Forward declare.
 namespace Json {

I'm not sure why this issue was attributed to the compiler being "pedantic" since std::array is used in CollectiveVariable.h e.g. on line 53: std::array<double, 2> bounds_;

(I do not get the problem related to lammps mentioned by @yurivict as I am building for Qbox).