Eli Gottlieb <eligottlieb at gmail.com> writes:> I compiled and installed it to the prefix /usr, but that's not the > issue. Once I actually compile and install LLVM with CMake by hand, I > get the share/llvm/cmake stuff installed correctly (can those files be > included in "normal" builds, or will LLVM switch to CMake as its > primary build system?). Now I'm running into the problem of cflags or > includes or something not being set properly.[snip]>> [ 9%] Building C object CMakeFiles/jllvm.dir/Analysis_wrap.c.o >> In file included from /usr/include/llvm-c/Core.h:36, >> from /usr/include/llvm-c/Analysis.h:22, >> from >> /home/eli/Programs/decac/src/jllvm/llvm/Analysis_wrap.c:190: >> /usr/include/llvm/System/DataTypes.h:46: error: #error "Must #define >> __STDC_LIMIT_MACROS before #including System/DataTypes.h" >> /usr/include/llvm/System/DataTypes.h:50: error: #error "Must #define >> __STDC_CONSTANT_MACROS before " "#including System/DataTypes.h" >> make[2]: *** [CMakeFiles/jllvm.dir/Analysis_wrap.c.o] Error 1 >> make[1]: *** [CMakeFiles/jllvm.dir/all] Error 2 >> make: *** [all] Error 2Yes, you must define __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS on your CMakeLists.txt. Put this before any add_executable/add_library that contains source files that uses LLVM stuff: add_definitions( -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS )
Works now, thank you. On 11/03/2010 03:30 PM, Óscar Fuentes wrote:> add_definitions( -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS )
After I actually get everything compiling, install the library, and load it from my Java program, I get the following:> Exception in thread "main" java.lang.UnsatisfiedLinkError: > /usr/lib/libjllvm.so: /usr/lib/libjllvm.so: undefined symbol: > _ZTVN10__cxxabiv120__si_class_type_infoEIf I have to guess, this means that the CMake stuff given is linking to the C++ libraries of LLVM when I wanted them linking to the C bindings. Any ideas? I definitely included the headers for the C bindings only. On 11/03/2010 03:30 PM, Óscar Fuentes wrote:> Eli Gottlieb<eligottlieb at gmail.com> writes: > >> I compiled and installed it to the prefix /usr, but that's not the >> issue. Once I actually compile and install LLVM with CMake by hand, I >> get the share/llvm/cmake stuff installed correctly (can those files be >> included in "normal" builds, or will LLVM switch to CMake as its >> primary build system?). Now I'm running into the problem of cflags or >> includes or something not being set properly. > [snip] > >>> [ 9%] Building C object CMakeFiles/jllvm.dir/Analysis_wrap.c.o >>> In file included from /usr/include/llvm-c/Core.h:36, >>> from /usr/include/llvm-c/Analysis.h:22, >>> from >>> /home/eli/Programs/decac/src/jllvm/llvm/Analysis_wrap.c:190: >>> /usr/include/llvm/System/DataTypes.h:46: error: #error "Must #define >>> __STDC_LIMIT_MACROS before #including System/DataTypes.h" >>> /usr/include/llvm/System/DataTypes.h:50: error: #error "Must #define >>> __STDC_CONSTANT_MACROS before " "#including System/DataTypes.h" >>> make[2]: *** [CMakeFiles/jllvm.dir/Analysis_wrap.c.o] Error 1 >>> make[1]: *** [CMakeFiles/jllvm.dir/all] Error 2 >>> make: *** [all] Error 2 > Yes, you must define __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS on > your CMakeLists.txt. Put this before any add_executable/add_library that > contains source files that uses LLVM stuff: > > add_definitions( -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS )
Oh, and I've definitely configured CMake to compile everything as C. project(jllvm C) On 11/03/2010 10:56 PM, Eli Gottlieb wrote:> After I actually get everything compiling, install the library, and > load it from my Java program, I get the following: >> Exception in thread "main" java.lang.UnsatisfiedLinkError: >> /usr/lib/libjllvm.so: /usr/lib/libjllvm.so: undefined symbol: >> _ZTVN10__cxxabiv120__si_class_type_infoE > If I have to guess, this means that the CMake stuff given is linking > to the C++ libraries of LLVM when I wanted them linking to the C > bindings. Any ideas? I definitely included the headers for the C > bindings only. > On 11/03/2010 03:30 PM, Óscar Fuentes wrote: >> Eli Gottlieb<eligottlieb at gmail.com> writes: >> >>> I compiled and installed it to the prefix /usr, but that's not the >>> issue. Once I actually compile and install LLVM with CMake by hand, I >>> get the share/llvm/cmake stuff installed correctly (can those files be >>> included in "normal" builds, or will LLVM switch to CMake as its >>> primary build system?). Now I'm running into the problem of cflags or >>> includes or something not being set properly. >> [snip] >> >>>> [ 9%] Building C object CMakeFiles/jllvm.dir/Analysis_wrap.c.o >>>> In file included from /usr/include/llvm-c/Core.h:36, >>>> from /usr/include/llvm-c/Analysis.h:22, >>>> from >>>> /home/eli/Programs/decac/src/jllvm/llvm/Analysis_wrap.c:190: >>>> /usr/include/llvm/System/DataTypes.h:46: error: #error "Must #define >>>> __STDC_LIMIT_MACROS before #including System/DataTypes.h" >>>> /usr/include/llvm/System/DataTypes.h:50: error: #error "Must #define >>>> __STDC_CONSTANT_MACROS before " "#including System/DataTypes.h" >>>> make[2]: *** [CMakeFiles/jllvm.dir/Analysis_wrap.c.o] Error 1 >>>> make[1]: *** [CMakeFiles/jllvm.dir/all] Error 2 >>>> make: *** [all] Error 2 >> Yes, you must define __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS on >> your CMakeLists.txt. Put this before any add_executable/add_library that >> contains source files that uses LLVM stuff: >> >> add_definitions( -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS ) >
[Please don't top-post.] Eli Gottlieb <eligottlieb at gmail.com> writes:> After I actually get everything compiling, install the library, and > load it from my Java program, I get the following: >> Exception in thread "main" java.lang.UnsatisfiedLinkError: >> /usr/lib/libjllvm.so: /usr/lib/libjllvm.so: undefined symbol: >> _ZTVN10__cxxabiv120__si_class_type_infoE > If I have to guess, this means that the CMake stuff given is linking > to the C++ libraries of LLVM when I wanted them linking to the C > bindings. Any ideas? I definitely included the headers for the C > bindings only.The error is about missing RTTI support (C++ runtime type information). The C bindings are just a layer around the C++ LLVM libraries. More specifically, the LLVM libraries must be linked to the C++ runtime to work. So use g++ for linking or pass the C++ runtime libraries on the link command (stdc++ and maybe some other).
Eli Gottlieb <eligottlieb at gmail.com> writes:> So you're saying that the default CMake build of LLVM creates static > libraries that got linked into my shared-object and now require me to > link in everything they require myself? Shouldn't the linker be able > to track down C++ runtime for this?You told CMake to manage your shared library as if it were a pure C application, which isn't (because it links to static LLVM libraries.) The linker is doing what you requested: link a C executable. So either you add the required C++ libraries yourself, or link the shared library as a C++ executable.
On Nov 4, 2010, at 11:48 AM, Óscar Fuentes wrote:> Eli Gottlieb <eligottlieb at gmail.com> writes: > >> So you're saying that the default CMake build of LLVM creates static >> libraries that got linked into my shared-object and now require me to >> link in everything they require myself? Shouldn't the linker be able >> to track down C++ runtime for this? > > You told CMake to manage your shared library as if it were a pure C > application, which isn't (because it links to static LLVM libraries.) > The linker is doing what you requested: link a C executable. > > So either you add the required C++ libraries yourself, or link the > shared library as a C++ executable.So... couldn't I just tell it to compile LLVM as shared libraries instead of static?