davpoolechem / JuliaChem.jl

A research-grade quantum chemistry program written in Julia
MIT License
63 stars 14 forks source link

Build can't find julia.h, issue with JlCXX? #23

Closed TyBalduf closed 4 years ago

TyBalduf commented 4 years ago

I'm trying to build JuliaChem using julia1.5.2 in Ubuntu 20.04 (WSL). When I follow the instructions from the README, I get the following error:

(@v1.5) pkg> build JuliaChem
   Building MPI ──────→ `~/.julia/packages/MPI/z1lDn/deps/build.log`
   Building HDF5 ─────→ `~/.julia/packages/HDF5/T1b9x/deps/build.log`
   Building JuliaChem → `~/JuliaChem/JuliaChem.jl/deps/build.log`
┌ Error: Error building `JuliaChem`:
│ -- The C compiler identification is GNU 9.3.0
│ -- The CXX compiler identification is GNU 9.3.0
│ -- 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
│ -- 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
│ -- CMAKE_BUILD_TYPE: Release
│ -- Found Eigen at /home/ty/.julia/artifacts/07c0d2d7fd9739e16a8520ca528468a3d9b019e5
│ -- Found Boost at /home/ty/.julia/artifacts/4b2bbd47bef5cb3482165d39ac9d89fb058da2cd
│ -- Found JLCxx at /home/ty/.julia/artifacts/fd5dfb5dee87c41c238d98bd7ff2fdd4f307e824
│ -- Found Libint at /home/ty/libint-2.6.0
│ -- Configuring done
│ -- Generating done
│ -- Build files have been written to: /home/ty/JuliaChem/JuliaChem.jl/deps/build
│ Scanning dependencies of target jeri
│ [ 50%] Building CXX object CMakeFiles/jeri.dir/src/jeri.cpp.o
│ In file included from /home/ty/.julia/artifacts/fd5dfb5dee87c41c238d98bd7ff2fdd4f307e824/include/jlcxx/array.hpp:4,
│                  from /home/ty/.julia/artifacts/fd5dfb5dee87c41c238d98bd7ff2fdd4f307e824/include/jlcxx/jlcxx.hpp:13,
│                  from /home/ty/JuliaChem/JuliaChem.jl/deps/src/jeri-core.hpp:5,
│                  from /home/ty/JuliaChem/JuliaChem.jl/deps/src/jeri.cpp:1:
│ /home/ty/.julia/artifacts/fd5dfb5dee87c41c238d98bd7ff2fdd4f307e824/include/jlcxx/type_conversion.hpp:4:10: fatal error: julia.h: No such file or directory
│     4 | #include <julia.h>
│       |          ^~~~~~~~~
│ compilation terminated.
│ make[2]: *** [CMakeFiles/jeri.dir/build.make:63: CMakeFiles/jeri.dir/src/jeri.cpp.o] Error 1
│ make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/jeri.dir/all] Error 2
│ make: *** [Makefile:130: all] Error 2
│ ERROR: LoadError: failed process: Process(`make`, ProcessExited(2)) [2]
│
│ Stacktrace:
│  [1] pipeline_error at ./process.jl:525 [inlined]
│  [2] run(::Cmd; wait::Bool) at ./process.jl:440
│  [3] run at ./process.jl:438 [inlined]
│  [4] build_jeri() at /home/ty/JuliaChem/JuliaChem.jl/deps/build.jl:16
│  [5] top-level scope at /home/ty/JuliaChem/JuliaChem.jl/deps/build.jl:20
│  [6] include(::String) at ./client.jl:457
│  [7] top-level scope at none:5
│ in expression starting at /home/ty/JuliaChem/JuliaChem.jl/deps/build.jl:20
└ @ Pkg.Operations /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/Pkg/src/Operations.jl:949

It seems that it can't find the julia.h , but I have seen that this in my installed at /opt/julia-1.5.2/include/julia/julia.h. Is there somewhere else where it looks for this file? Or are there version restrictions for which Julia this will work for?

davpoolechem commented 4 years ago

Hi,

Thank you for pointing this issue out!

I just took a look at the deps/CMakeLists.txt file, and it does not explicitly search for a Julia directory - at all. I think this works for me because I typically define a number of environment variables on the side, but yeah, this wouldn't work normally. And those env. variables shouldn't have to be defined for JuliaChem.jl to work.

I just added an update branch in response to this issue, davpoole/build-issue. It explicitly searches for Julia (and Libint) directories during the CMake process. You can define JULIA_ROOT as an environment variable to designate the Julia directory if you wish, but it shouldn't be necessary. Let me know if the new branch works.

TyBalduf commented 4 years ago

I was able to compile, but it required some small changes.

  1. In deps/CMakeLists.txt, I changed line 44 from ${JULIA_PATH}/include/julia to ${JULIA_PATH}/../include/julia. For my installation, JULIA_PATH directs to the julia executable in bin, so I have to move up a directory to find include/julia.

  2. I had to include export CXXFLAGS="$CXXFLAGS -fPIC" in my rc file before compiling libint, otherwise I got an error that certain parts of the library weren't shareable objects:

    /usr/bin/ld: /usr/local/lib/libint2.a(libint2_static_init.cc.o): relocation R_X86_64_PC32 against symbol 'libint2_build_overlap' can not be used when making a shared object; recompile with -fPIC
  3. I installed julia from the precompiled binary. This seems like it can create issues with GLIBCXX not being up to date. In this case, JuliaChem would build, but would fail with:

    using JuliaChem`: `ERROR: LoadError: LoadError: could not load library "/home/ty/JuliaChem/JuliaChem.jl/deps/src/../libjeri.so"
    /home/ty/julia-1.5.2/bin/../lib/julia/libstdc++.so.6: version `GLIBCXX_3.4.26' not found (required by /home/ty/JuliaChem/JuliaChem.jl/deps/src/../libjeri.so)

    To fix this, I used the workaround discussed here of copying the up to date system version of libstdc++.so.6 into the julia libraries.