Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

external BOOST library not properly picked up #2

Open
stiobhan opened this issue Mar 19, 2019 · 7 comments · May be fixed by #7
Open

external BOOST library not properly picked up #2

stiobhan opened this issue Mar 19, 2019 · 7 comments · May be fixed by #7
Assignees
Labels
bug Something isn't working

Comments

@stiobhan
Copy link

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 execute make it fails at some point because the compiler doesn't find the header files:

$ cmake .. -DBOOST_ROOT=$BOOST_HOME
-- The CXX compiler identification is GNU 7.3.0
-- The C compiler identification is GNU 7.3.0
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Boost version: 1.68.0
-- Found LAPACKE: /usr/include/x86_64-linux-gnu  
-- Found GROMACS: 2018.4
CMake Warning at /opt/tcbsys/gromacs/2018.4/AVX2_256/share/cmake/gromacs/gromacs-config.cmake:132 (message):
  You are compiling with a different C++ compiler from the one that was used
  to compile GROMACS.  This may lead to linking or runtime problems.  GROMACS
  was compiled with GNU 5.4.0 (/usr/bin/g++-5).
Call Stack (most recent call first):
  CMakeLists.txt:87 (gromacs_check_compiler)


-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/src/chap-version_0_9_1/build

$ make
Scanning dependencies of target googletest
[  0%] Creating directories for 'googletest'
[  1%] Performing download step (download, verify and extract) for 'googletest'
-- Downloading...
   dst='/tmp/src/chap-version_0_9_1/build/googletest-prefix/src/release-1.7.0.zip'
   timeout='none'
-- Using src='https://github.com/google/googletest/archive/release-1.7.0.zip'
-- [download 0% complete]
[...]
-- [download 100% complete]
-- Downloading... done
-- extracting...
     src='/tmp/src/chap-version_0_9_1/build/googletest-prefix/src/release-1.7.0.zip'
     dst='/tmp/src/chap-version_0_9_1/build/googletest-prefix/src/googletest'
-- extracting... [tar xfz]
-- extracting... [analysis]
-- extracting... [rename]
-- extracting... [clean up]
-- extracting... done
[  2%] No patch step for 'googletest'
[  3%] No update step for 'googletest'
[  3%] Performing configure step for 'googletest'
-- The CXX compiler identification is GNU 7.3.0
-- The C compiler identification is GNU 7.3.0
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Found PythonInterp: /usr/bin/python (found version "2.7.15") 
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/src/chap-version_0_9_1/build/googletest-prefix/src/googletest-build
[  4%] Performing build step for 'googletest'
Scanning dependencies of target gtest
[ 25%] Building CXX object CMakeFiles/gtest.dir/src/gtest-all.cc.o
[ 50%] Linking CXX static library libgtest.a
[ 50%] Built target gtest
Scanning dependencies of target gtest_main
[ 75%] Building CXX object CMakeFiles/gtest_main.dir/src/gtest_main.cc.o
[100%] Linking CXX static library libgtest_main.a
[100%] Built target gtest_main
[  5%] No install step for 'googletest'
[  6%] Completed 'googletest'
[  6%] Built target googletest
Scanning dependencies of target chap
[  6%] Building CXX object CMakeFiles/chap.dir/src/aggregation/boltzmann_energy_calculator.cpp.o
[  7%] Building CXX object CMakeFiles/chap.dir/src/aggregation/multiscalar_time_series.cpp.o
[  8%] Building CXX object CMakeFiles/chap.dir/src/aggregation/number_density_calculator.cpp.o
[  9%] Building CXX object CMakeFiles/chap.dir/src/aggregation/scalar_time_series.cpp.o
[  9%] Building CXX object CMakeFiles/chap.dir/src/analysis-setup/residue_information_provider.cpp.o
[ 10%] Building CXX object CMakeFiles/chap.dir/src/config/back_matter.cpp.o
[ 11%] Building CXX object CMakeFiles/chap.dir/src/config/front_matter.cpp.o
[ 12%] Building CXX object CMakeFiles/chap.dir/src/geometry/abstract_cubic_spline_interp.cpp.o
[ 12%] Building CXX object CMakeFiles/chap.dir/src/geometry/abstract_spline_curve.cpp.o
[ 13%] Building CXX object CMakeFiles/chap.dir/src/geometry/basis_spline.cpp.o
[ 14%] Building CXX object CMakeFiles/chap.dir/src/geometry/bspline_basis_set.cpp.o
[ 15%] Building CXX object CMakeFiles/chap.dir/src/geometry/cubic_spline_interp_1D.cpp.o
[ 16%] Building CXX object CMakeFiles/chap.dir/src/geometry/cubic_spline_interp_3D.cpp.o
[ 16%] Building CXX object CMakeFiles/chap.dir/src/geometry/linear_spline_interp_1D.cpp.o
[ 17%] Building CXX object CMakeFiles/chap.dir/src/geometry/spline_curve_1D.cpp.o
/tmp/src/chap-version_0_9_1/src/geometry/spline_curve_1D.cpp:28:10: fatal error: boost/math/tools/minima.hpp: No such file or directory
 #include <boost/math/tools/minima.hpp>
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
CMakeFiles/chap.dir/build.make:398: recipe for target 'CMakeFiles/chap.dir/src/geometry/spline_curve_1D.cpp.o' failed
make[2]: *** [CMakeFiles/chap.dir/src/geometry/spline_curve_1D.cpp.o] Error 1
CMakeFiles/Makefile2:355: recipe for target 'CMakeFiles/chap.dir/all' failed
make[1]: *** [CMakeFiles/chap.dir/all] Error 2
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2

Running make in verbose mode shows that the compiler command line is missing the flag -I/path/to/boost/include:

$ make VERBOSE=1
/usr/bin/cmake -H/tmp/src/chap-version_0_9_1 -B/tmp/src/chap-version_0_9_1/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /tmp/src/chap-version_0_9_1/build/CMakeFiles /tmp/src/chap-version_0_9_1/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/tmp/src/chap-version_0_9_1/build'
make -f CMakeFiles/googletest.dir/build.make CMakeFiles/googletest.dir/depend
make[2]: Entering directory '/tmp/src/chap-version_0_9_1/build'
cd /tmp/src/chap-version_0_9_1/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /tmp/src/chap-version_0_9_1 /tmp/src/chap-version_0_9_1 /tmp/src/chap-version_0_9_1/build /tmp/src/chap-version_0_9_1/build /tmp/src/chap-version_0_9_1/build/CMakeFiles/googletest.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/tmp/src/chap-version_0_9_1/build'
make -f CMakeFiles/googletest.dir/build.make CMakeFiles/googletest.dir/build
make[2]: Entering directory '/tmp/src/chap-version_0_9_1/build'
make[2]: Nothing to be done for 'CMakeFiles/googletest.dir/build'.
make[2]: Leaving directory '/tmp/src/chap-version_0_9_1/build'
[  6%] Built target googletest
make -f CMakeFiles/chap.dir/build.make CMakeFiles/chap.dir/depend
make[2]: Entering directory '/tmp/src/chap-version_0_9_1/build'
cd /tmp/src/chap-version_0_9_1/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /tmp/src/chap-version_0_9_1 /tmp/src/chap-version_0_9_1 /tmp/src/chap-version_0_9_1/build /tmp/src/chap-version_0_9_1/build /tmp/src/chap-version_0_9_1/build/CMakeFiles/chap.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/tmp/src/chap-version_0_9_1/build'
make -f CMakeFiles/chap.dir/build.make CMakeFiles/chap.dir/build
make[2]: Entering directory '/tmp/src/chap-version_0_9_1/build'
[  7%] Building CXX object CMakeFiles/chap.dir/src/geometry/spline_curve_1D.cpp.o
/usr/bin/c++  -DGMX_DOUBLE=0 -DRAPIDJSON_HAS_STDSTRING -I/opt/tcbsys/gromacs/2018.4/AVX2_256/include -I/tmp/src/chap-version_0_9_1/build/googletest-prefix/src/googletest/include -I/tmp/src/chap-version_0_9_1/build -I/tmp/src/chap-version_0_9_1/include  -O3 -DNDEBUG   -std=c++11 -o CMakeFiles/chap.dir/src/geometry/spline_curve_1D.cpp.o -c /tmp/src/chap-version_0_9_1/src/geometry/spline_curve_1D.cpp
/tmp/src/chap-version_0_9_1/src/geometry/spline_curve_1D.cpp:28:10: fatal error: boost/math/tools/minima.hpp: No such file or directory
 #include <boost/math/tools/minima.hpp>
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
CMakeFiles/chap.dir/build.make:398: recipe for target 'CMakeFiles/chap.dir/src/geometry/spline_curve_1D.cpp.o' failed
make[2]: *** [CMakeFiles/chap.dir/src/geometry/spline_curve_1D.cpp.o] Error 1
make[2]: Leaving directory '/tmp/src/chap-version_0_9_1/build'
CMakeFiles/Makefile2:355: recipe for target 'CMakeFiles/chap.dir/all' failed
make[1]: *** [CMakeFiles/chap.dir/all] Error 2
make[1]: Leaving directory '/tmp/src/chap-version_0_9_1/build'
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2

CMakeCache.txt is attached
CMakeCache.txt

@yongwangCPH
Copy link

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
#include <boost/config/no_tr1/cmath.hpp>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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

@channotation channotation added the bug Something isn't working label Apr 9, 2019
@Inniag
Copy link
Collaborator

Inniag commented Jun 25, 2019

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.

@yongwangCPH
Copy link

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]
#ifndef GAUSSIAN_DENSITY_DERIVATIVE_HPP
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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'?
#define GAUSSIAN_DENSITY_DERUVATIVE_HPP
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
GAUSSIAN_DENSITY_DERIVATIVE_HPP
/Users/wyong/Work/Softwares/chap-version_0_9_1/src/trajectory-analysis/chap_trajectory_analysis.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_trajectory_analysis.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_trajectory_analysis.cpp:87:38: 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_trajectory_analysis.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_trajectory_analysis.cpp:87:52: 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_trajectory_analysis.cpp:87:52: note: insert an explicit cast to
silence this issue
pfInitProbePos_ = {std::nan(""), std::nan(""), std::nan("")};
^~~~~~~~~~~~
static_cast( )
In file included from /Users/wyong/Work/Softwares/chap-version_0_9_1/src/trajectory-analysis/chap_trajectory_analysis.cpp:25:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/algorithm:644:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:2335:5: warning: delete called on
'AbstractPathFinder' that is abstract but has non-virtual destructor [-Wdelete-non-virtual-dtor]
delete __ptr;
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:2648:7: note: in instantiation of
member function 'std::__1::default_delete::operator()' requested here
_ptr.second()(__tmp);
^
/Users/wyong/Work/Softwares/chap-version_0_9_1/src/trajectory-analysis/chap_trajectory_analysis.cpp:959:13: note: in instantiation of member
function 'std::__1::unique_ptr<AbstractPathFinder, std::_1::default_delete >::reset' requested here
pfm.reset(new InplaneOptimisedProbePathFinder(pfPar
,
^
In file included from /Users/wyong/Work/Softwares/chap-version_0_9_1/src/trajectory-analysis/chap_trajectory_analysis.cpp:25:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/algorithm:644:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:2335:5: warning: delete called on
'AbstractDensityEstimator' that is abstract but has non-virtual destructor [-Wdelete-non-virtual-dtor]
delete __ptr;
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:2648:7: note: in instantiation of
member function 'std::__1::default_delete::operator()' requested here
_ptr.second()(__tmp);
^
/Users/wyong/Work/Softwares/chap-version_0_9_1/src/trajectory-analysis/chap_trajectory_analysis.cpp:1314:26: note: in instantiation of
member function 'std::__1::unique_ptr<AbstractDensityEstimator, std::__1::default_delete >::reset' requested
here
densityEstimator.reset(new HistogramDensityEstimator());
^
10 warnings and 3 errors generated.
make[2]: *** [CMakeFiles/chap.dir/src/trajectory-analysis/chap_trajectory_analysis.cpp.o] Error 1
make[1]: *** [CMakeFiles/chap.dir/all] Error 2
make: *** [all] Error 2

@stiobhan
Copy link
Author

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.

@Inniag
Copy link
Collaborator

Inniag commented Jun 25, 2019

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?

@yongwangCPH
Copy link

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/

@Inniag
Copy link
Collaborator

Inniag commented Jun 26, 2019

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants