LLVM on Mac OS X Lion

2.3k views Asked by At

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

There are 1 answers

0
arrowd On

Use llvm-config utility to get all necessary flags.

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