1. Zachary Anderson
  2. cil-template
  3. Issues
Issue #3 new

Failing to build with opam

Gabriel Kerneis
created an issue

I have a system-wide Debian ocaml installation as well as a local opam-based one. Everything works correctly for me (thanks to eval opam config env), except when I try to build this tutorial. Cmake ignores my environment variables and invokes my system-wide ocamlfind, where CIL is not installed, instead of the opam one. Is there a way to fix this?

cil-template/build$ cmake ..
-- The C compiler identification is GNU 4.7.3
-- The CXX compiler identification is GNU 4.7.3
-- 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
-- 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
-- Looking for clock_gettime in rt
-- Looking for clock_gettime in rt - found
-- Looking for dlopen in dl
-- Looking for dlopen in dl - found
-- Found OCAML: 3.12.1  
isntall prefix = /usr/local/lib/ciltut/
PPARGS = 
-- Found unix: [distributed with Ocaml]  
-- Found str: [distributed with Ocaml]  
-- Found ocamlgraph: 1.8.2  
ocamlfind: Package `cil' not found
ocamlfind: Package `cil' not found
-- Could NOT find cil (missing:  OCAML_CIL_VERSION OCAML_CIL_INCLUDE_DIR) 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/gabriel/repos/cil-template/build
cil-template/build$ which ocamlfind
/home/gabriel/.opam/system/bin/ocamlfind
cil-template/build$ ocamlfind query cil
/home/gabriel/.opam/system/lib/cil
cil-template/build$ /usr/bin/ocamlfind query cil
ocamlfind: Package `cil' not found

Comments (2)

  1. Zachary Anderson repo owner

    I think I see how I could fix this in CMakeModules/FindOCaml.cmake by specifying a PATHS argument to the initial find_program() call. Is there a common environment variable for the path to the ocaml that you want?

  2. Gabriel Kerneis reporter

    Opam defines the following variables:

    #!shell
    $ opam config env
    CAML_LD_LIBRARY_PATH=/home/gabriel/.opam/system/lib/stublibs:/usr/lib/ocaml/stublibs; export CAML_LD_LIBRARY_PATH;
    OCAML_TOPLEVEL_PATH=/home/gabriel/.opam/system/lib/toplevel; export OCAML_TOPLEVEL_PATH;
    MANPATH=/home/gabriel/.opam/system/man:; export MANPATH;
    PATH=/home/gabriel/.opam/system/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games; export PATH;
    

    So PATH, CAML_LD_LIBRARY_PATH and OCAML_TOPLEVEL_PATH should be enough I guess (and work even for people hacking their own local compiler without using opam).

  3. Log in to comment