skip to Main Content

I am having problems installing c2ffi (https://github.com/rpav/c2ffi) on both FreeBSD 12 and Debian 10. I need c2ffi in order to use some Common Lisp bindings that rely on c2ffi.

On FreeBSD 12, I have both Clang 6.0 (default) and 10.0 installed; c2ffi requires LLVM 10.0. Because cc and c++ refer to Clang 6.0 in my FreeBSD installation, I set PATH to /usr/local/llvm10/bin:$PATH, and I also set aliases to refer to clang and clang++. I have cmake version 3.17.3 installed. However, when I make it to the make phase of installing c2ffi, I run into the following error:

Scanning dependencies of target c2ffi
[  7%] Building CXX object CMakeFiles/c2ffi.dir/src/AST.cpp.o
[ 15%] Building CXX object CMakeFiles/c2ffi.dir/src/Decl.cpp.o
[ 23%] Building CXX object CMakeFiles/c2ffi.dir/src/Expr.cpp.o
[ 30%] Building CXX object CMakeFiles/c2ffi.dir/src/OutputDriver.cpp.o
[ 38%] Building CXX object CMakeFiles/c2ffi.dir/src/Template.cpp.o
[ 46%] Building CXX object CMakeFiles/c2ffi.dir/src/Type.cpp.o
[ 53%] Building CXX object CMakeFiles/c2ffi.dir/src/c2ffi.cpp.o
[ 61%] Building CXX object CMakeFiles/c2ffi.dir/src/drivers/JSON.cpp.o
/home/michael/c2ffi/src/drivers/JSON.cpp:36:26: warning: passing an object that
      undergoes default argument promotion to 'va_start' has undefined behavior
      [-Wvarargs]
            va_start(ap, close);
                         ^
/home/michael/c2ffi/src/drivers/JSON.cpp:32:61: note: parameter of type 'bool'
      is declared here
        void write_object(const char *type, bool open, bool close, ...) {
                                                            ^
1 warning generated.
[ 69%] Building CXX object CMakeFiles/c2ffi.dir/src/drivers/Null.cpp.o
[ 76%] Building CXX object CMakeFiles/c2ffi.dir/src/drivers/Sexp.cpp.o
[ 84%] Building CXX object CMakeFiles/c2ffi.dir/src/init.cpp.o
[ 92%] Building CXX object CMakeFiles/c2ffi.dir/src/options.cpp.o
[100%] Linking CXX executable bin/c2ffi
/usr/bin/ld: error: unable to find library -lclang-cpp
c++: error: linker command failed with exit code 1 (use -v to see invocation)
*** Error code 1

Stop.
make[2]: stopped in /usr/home/michael/c2ffi/build
*** Error code 1

Stop.
make[1]: stopped in /usr/home/michael/c2ffi/build
*** Error code 1

Stop.
make: stopped in /usr/home/michael/c2ffi/build

The file libclang-cpp.so is present in my /usr/local/llvm10/lib directory, but cmake does not detect it. I tried various other approaches, including setting the LD_LIBRARY_PATH and CMAKE_LIBRARY_PATH environment variables, but to no avail; I received the same error message as above.

I gave up installing c2ffi on FreeBSD and tried installing it on a fresh install of Debian 10 with LLVM 10.0 and cmake 3.18.1. However, when I ran make on Debian, I ended up with the following error message:

[  7%] Building CXX object CMakeFiles/c2ffi.dir/src/AST.cpp.o
/home/michael/c2ffi/src/AST.cpp:24:10: fatal error: 'clang/AST/ASTConsumer.h' file not found
#include <clang/AST/ASTConsumer.h>
         ^~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [CMakeFiles/c2ffi.dir/build.make:82: CMakeFiles/c2ffi.dir/src/AST.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:123: CMakeFiles/c2ffi.dir/all] Error 2
make: *** [Makefile:149: all] Error 2

I am wondering how I can build c2ffi on my FreeBSD and Debian systems?

2

Answers


  1. Chosen as BEST ANSWER

    On my FreeBSD installation, in the CMakeLists.txt I replaced the line

    target_link_libraries(c2ffi PUBLIC clang-cpp LLVM)
    

    with

    target_link_libraries(c2ffi PUBLIC /usr/local/llvm10/lib/libclang-cpp.so LLVM)
    

    On my Debian installation, it turned out that I did not have one of the libclang development packages installed. After installing that package I was able to run make without any problems.


  2. The project’s CMakeLists.txt is broken, so bug upstream. Actualy, there are numerous pull requests already filed:

    You can try these, or combine them into a working solution.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search