1

I am trying to make LLVM to work on my Mac. I want to write cpp code and generate LLVM IR. I have installed llvm-gcc42 and all the dependencies using MacPorts:

expat @2.0.1_1 (active)
gettext @0.18.1.1_2 (active)
gmp @5.0.2_1 (active)
gperf @3.0.4_2 (active)
ld64 @127.2_1 (active)
libffi @3.0.10_2 (active)
libiconv @1.14_0 (active)
libunwind-headers @30_0 (active)
llvm-2.9 @2.9_1 (active)
llvm-3.0 @3.0_1 (active)
llvm-gcc42 @2.9_1 (active)
llvm_select @0.2_0 (active)
mpfr @3.1.0-p3_0 (active)
ncurses @5.9_1 (active)
ncursesw @5.8_0 (active)
xz @5.0.3_0 (active)

When I try to compile a simple cpp file with one included llvm header, it says that the header is not found:

llvm.cpp:2:25: error: llvm/Module.h: No such file or directory

This is the source file:

#include <iostream>
#include "llvm/Module.h"

using namespace std;

int main(int argc, char *argv[]) {
    cout << "Hello World!" << endl;
    return 0;
}

I am wondering if anybody can help me. Thanks

  • 1
    I don't think you need MacPorts for that (I would certainly avoid them) - just grab LLVM sources, everything else comes already with Xcode. But if you don't install it in the default location, you probably need `-I` pointing to the `include` directory in LLVM as you compile your file (and corresponding linker flags). – Simon Urbanek Jan 10 '12 at 02:44

1 Answers1

3

Use llvm-config utility to get all necessary flags.

Also, try to use clang instead of llvm-gcc, since the latter is deprecated.

arrowd
  • 33,231
  • 8
  • 79
  • 110