Open stiobhan opened 5 years ago
I also have the same problem when I compiled CHAP in my mac, even that I tried to specify BOOST path by:
cmake .. -DBOOST_ROOT=/usr/local/Cellar/boost/1.69.0/ -DBOOST_INCLUDEDIR=/usr/local/Cellar/boost/1.69.0/include/
The errors I got is:
In file included from /Users/wyong/Work/Softwares/chap-version_0_8_0/src/geometry/spline_curve_1D.cpp:29: /usr/local/Cellar/boost/1.69.0/include/boost/math/tools/minima.hpp:15:10: fatal error: 'boost/config/no_tr1/cmath.hpp' file not found
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated. make[2]: [CMakeFiles/chap.dir/src/geometry/spline_curve_1D.cpp.o] Error 1 make[1]: [CMakeFiles/chap.dir/all] Error 2 make: *** [all] Error 2
Thanks for pointing out this issue! I've so far only installed/tested CHAP with dependencies in standard install paths and so haven't come across this problem yet.
I think it is due to CMake not telling the compiler where to find the Boost headers. If those are in a standard location, gcc will pick them up anyway, otherwise compilation fails as you describe.
What should fix this is to add
target_include_directories(chap PUBLIC ${Boost_INCLUDE_DIRS})
to CMakeLists.txt
(in line 157, just before linking to the Boost library). A similar addition may be necessary in CMakeLists.txt
in the test
subdirectory.
If you can confirm that this fixes the problem, I should be able to patch this quickly.
Thanks for the help. It seems helpful by adding "target_include_directories(chap PUBLIC ${Boost_INCLUDE_DIRS})" in CMakeLists.txt. But now I got new errors:
In file included from /Users/wyong/Work/Softwares/chap-version_0_9_1/src/trajectory-analysis/chap_trajectory_analysis.cpp:54: In file included from /Users/wyong/Work/Softwares/chap-version_0_9_1/include/statistics/amise_optimal_bandwidth_estimator.hpp:36: /Users/wyong/Work/Softwares/chap-version_0_9_1/include/statistics/gaussian_density_derivative.hpp:25:9: warning: 'GAUSSIAN_DENSITY_DERIVATIVE_HPP' is used as a header guard here, followed by #define of a different macro [-Wheader-guard]
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/wyong/Work/Softwares/chap-version_0_9_1/include/statistics/gaussian_density_derivative.hpp:26:9: note: 'GAUSSIAN_DENSITY_DERUVATIVE_HPP' is defined here; did you mean 'GAUSSIAN_DENSITY_DERIVATIVE_HPP'?
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
GAUSSIAN_DENSITY_DERIVATIVE_HPP
/Users/wyong/Work/Softwares/chap-version_0_9_1/src/trajectory-analysis/chap_trajectoryanalysis.cpp:87:24: error: non-constant-expression
cannot be narrowed from type 'double' to 'float' in initializer list [-Wc++11-narrowing]
pfInitProbePos = {std::nan(""), std::nan(""), std::nan("")};
^~~~
/Users/wyong/Work/Softwares/chap-version_0_9_1/src/trajectory-analysis/chap_trajectoryanalysis.cpp:87:24: note: insert an explicit cast to
silence this issue
pfInitProbePos = {std::nan(""), std::nan(""), std::nan("")};
^~~~
static_cast~~~
/Users/wyong/Work/Softwares/chap-version_0_9_1/src/trajectory-analysis/chap_trajectoryanalysis.cpp:87:38: note: insert an explicit cast to
silence this issue
pfInitProbePos = {std::nan(""), std::nan(""), std::nan("")};
^~~~
static_cast~~~
/Users/wyong/Work/Softwares/chap-version_0_9_1/src/trajectory-analysis/chap_trajectoryanalysis.cpp:87:52: note: insert an explicit cast to
silence this issue
pfInitProbePos = {std::nan(""), std::nan(""), std::nan("")};
^~~~
static_cast
In my case adding
target_include_directories(chap PUBLIC ${Boost_INCLUDE_DIRS})
in CMakeLists.txt
and
target_include_directories(runAllTests PUBLIC ${Boost_INCLUDE_DIRS})
in test/CMakeLists.txt
fixes the problems I've seen. I'm compiling on Ubuntu 18.04 with GCC 7.
Thanks for the quick feedback, I'll try to get an official patch ready asap.
@yongwangCPH, your issue now seems to be something completely different and I suspect it originates from using a different compiler version or different compiler settings from what @stiobhan and I are using. Could you provide your OS and compiler versions?
I am using MacOS Mojave and AppleClang 10.0.1 compiler. I also pasted the cmake command as below:
cmake ../ -DLAPACKE_CBLAS_INCLUDE_DIR=/usr/local/opt/lapack/include -DCMAKE_PREFIX_PATH=/Users/wyong/Work/Softwares/GMX2016.5/share/cmake/gromacs_mpi/ -DBOOST_ROOT=/usr/local/Cellar/boost/1.69.0/ -DBOOST_INCLUDEDIR=/usr/local/Cellar/boost/1.69.0/include/ -DBOOST_LIBRARYDIR=/usr/local/Cellar/boost/1.69.0/lib/
@yongwangCPH , I think what you are seeing is a new problem separate from the BOOST library. Could you perhaps create a separate issue for this?
I've never worked with MacOS or the Clang compiler, so this is a bit of a guess: Most of the output that you posted is just warnings that can probably be safely ignored (the header guard issue is an easily fixable typo). The only proper error that stops Clang from finishing is the narrowing conversion, but that too sounds like a rather strict interpretation of the C++ standard as NaN should be the same for float and double (and gcc seems fine with it). So my hope would be that there is a Clang compiler flag that makes it treat -Wc++11-narrowing
as a warning rather than an error.
I noticed an issue when building with a BOOST library that is installed in a non-standard location. I can get cmake to pick it up by setting
-DBOOST_ROOT=/path/to/boost
, but when I executemake
it fails at some point because the compiler doesn't find the header files:Running make in verbose mode shows that the compiler command line is missing the flag
-I/path/to/boost/include
:CMakeCache.txt is attached CMakeCache.txt