llvm library linking issues

This is a discussion on llvm library linking issues within the C++ Programming forums, part of the General Programming Boards category; I'm trying to link make use of the llvm compiler libraries, but I can't get them to link to my ...

  1. #1
    Registered User
    Join Date
    Apr 2006
    Posts
    2,053

    llvm library linking issues

    I'm trying to link make use of the llvm compiler libraries, but I can't get them to link to my program correctly.

    Code:
    #include <llvm/Constants.h>
    #include <llvm/DerivedTypes.h>
    
    int main(){
        llvm::APInt(1,0);
        return 0;
    }
    I get an error like:
    undefined reference to `llvm::APInt::initSlowCase(unsigned int, unsigned long long, bool)
    (this function is called by the inline APInt constructor)

    The library seems to be found correctly; it doesn't give any other errors. Using nm I can see the mangled function initSlowCase exactly where I expect it to be (though I cannot verify that the mangling is correct). I'm out of ideas of that could be wrong.

    I'm using kubuntu 12.04. Same error occurs with both clang++ and g++.
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Only thing I can think of: are you sure your headers and libraries match? Are they from the exact same version of llvm? It could be that it picks up one of the two from an unexpected location.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  3. #3
    Registered User
    Join Date
    Apr 2006
    Posts
    2,053
    I'm sure that the intended header and library match, but I did previously install an earlier version of llvm. I uninstalled it before upgrading, but maybe that process left behind some artefacts. If only I could find them.

    EDIT: I tried removing separately the include, and the library. In both cases if failed to find the necessary file. Which suggests it's looking at the right pair of files.
    Last edited by King Mir; 07-14-2012 at 07:37 PM.
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

  4. #4
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    I suggest writing to the LLVM Developers Mailing List <llvmdev@cs.uiuc.edu>. They probably can help you more.

    By the way, to verify mangling, you can use c++filt. It's a little utility that should come with the GCC and Clang installs.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linking a Library
    By Pixie in forum C++ Programming
    Replies: 1
    Last Post: 12-28-2007, 07:27 AM
  2. COM library and linking error
    By xhi in forum Windows Programming
    Replies: 1
    Last Post: 08-05-2007, 08:38 PM
  3. Linking Library File?
    By dkennington in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2006, 04:50 PM
  4. External Functions and Compiler linking issues
    By collymitch in forum C Programming
    Replies: 2
    Last Post: 04-07-2005, 05:17 PM
  5. Library Linking problem
    By Lynchie in forum C Programming
    Replies: 3
    Last Post: 07-23-2002, 09:49 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21