How to enable shared library build when using CMake for LLVM?

Problem: Ubuntu 10.10 does not provide LLVM CMake modules ( /usr/share/llvm ) or ( /usr/local/share/llvm ) when installing LLVM 2.8 from Ubuntu repositories.

So now I am compiling LLVM 2.8 using CMake and then installing it as follows:

 cmake .. make make install 

This will install the CMake modules that I need to bind LLVM in my library. The problem is that when I compile LLVM with CMake, only static libraries are compiled. I saw in the LLVM documentation that you can compile shared libraries using this parameter in CMake:

 cmake -DBUILD_SHARED_LIBS=true .. 

But now CMake returns this error:

 -- Target triple: i686-pc-linux-gnu -- Native target architecture is X86 -- Threads enabled. -- Building with -fPIC -- Targeting Alpha -- Targeting ARM -- Targeting Blackfin -- Targeting CBackend -- Targeting CellSPU -- Targeting CppBackend -- Targeting Mips -- Targeting MBlaze -- Targeting MSP430 -- Targeting PIC16 -- Targeting PowerPC -- Targeting Sparc -- Targeting SystemZ -- Targeting X86 -- Targeting XCore -- Configuring done CMake Error: The inter-target dependency graph contains the following strongly connected component (cycle): "LLVMARMCodeGen" of type SHARED_LIBRARY depends on "LLVMARMAsmPrinter" "LLVMARMAsmPrinter" of type SHARED_LIBRARY depends on "LLVMARMCodeGen" At least one of these targets is not a STATIC_LIBRARY. Cyclic dependencies are allowed only among static libraries. -- Build files have been written to: /llvm-2.8/build 

And I cannot compile it as a shared library, does anyone know how to solve this problem? I need shared libraries because they depend on many other tools.

Summary

1) LLVM 2.8 from the Ubuntu repository installs the LLVM shared libraries, but does not install the CMake modules that I need.

2) On the other hand, if I compile LLVM myself, it installs the CMake modules that I need, but I can only do this when compiling LLVM as a static library.

+6
c ++ cmake llvm makefile
source share
3 answers

After a lot of investigations (google, source and llvmdev mail-list), I found that this problem is actually a problem with release 2.8, compilation of shared libraries using CMake in this version is broken. Now I am moving my library to version 2.9rc1, which works fine and has already been planned for release in the near future, thanks for all the answers.

+4
source share

The LLVM 2.8 documentation does not mention creation using CMake.

Try. / Configure --enable-shared

+1
source share

Try reading this page and then ask llvmdev if this does not help.

0
source share

All Articles