Getting Kaleidoscope to compile

Hi all,

I've started work on a new programming language for which I am
considering using LLVM as the backend, and trying to experiment with
it using the Kaleidoscope demo compiler.

Taking the full source listing from
http://llvm.org/docs/tutorial/LangImpl3.html#code and trying to
compile it with the provided instructions gives me the following
errors:

a@a-desktop:~$ g++ -g -O3 toy.cpp `llvm-config --cppflags --ldflags
--libs core` -o toy
toy.cpp:5:30: error: llvm/LLVMContext.h: No such file or directory
toy.cpp:352: error: ‘getGlobalContext’ was not declared in this scope
toy.cpp: In member function ‘virtual llvm::Value* NumberExprAST::Codegen()’:
toy.cpp:358: error: ‘getGlobalContext’ was not declared in this scope
toy.cpp: In member function ‘virtual llvm::Value* BinaryExprAST::Codegen()’:
toy.cpp:379: error: ‘getDoubleTy’ is not a member of ‘llvm::Type’
toy.cpp:379: error: ‘getGlobalContext’ was not declared in this scope
toy.cpp: In member function ‘llvm::Function* PrototypeAST::Codegen()’:
toy.cpp:407: error: ‘getDoubleTy’ is not a member of ‘llvm::Type’
toy.cpp:407: error: ‘getGlobalContext’ was not declared in this scope
toy.cpp:408: error: ‘getDoubleTy’ is not a member of ‘llvm::Type’
toy.cpp: In member function ‘llvm::Function* FunctionAST::Codegen()’:
toy.cpp:454: error: ‘getGlobalContext’ was not declared in this scope
toy.cpp: In function ‘int main()’:
toy.cpp:543: error: ‘LLVMContext’ was not declared in this scope
toy.cpp:543: error: ‘Context’ was not declared in this scope
toy.cpp:543: error: ‘getGlobalContext’ was not declared in this scope

Am I doing something wrong?

Operating system: Ubuntu 9.04
LLVM was obtained with: apt-get install llvm

Probably you missed to install llvm-dev package with headers for llvm.

2010/1/4 Russell Wallace <russell.wallace@gmail.com>

I tried apt-get install llvm-dev just now, and it says it was already
installed, and when I again try compiling toy.cpp, it gives the same
set of error messages.

Hello

Am I doing something wrong?

Yes

Operating system: Ubuntu 9.04
LLVM was obtained with: apt-get install llvm

Consider checking out code from svn or at least use package for LLVM
2.6 release (as I can see, 9.04 has only 2.5)

I tried apt-get install llvm-dev just now, and it says it was already
installed, and when I again try compiling toy.cpp, it gives the same
set of error messages.

According to this site:
Ubuntu – Package Search Results -- llvm 9.04 package is LLVM
2.5 which is too old and not compatible with the code from the site.
Checkout code from SVN or use 2.6 package.

I tried apt-get install llvm-dev just now, and it says it was already
installed, and when I again try compiling toy.cpp, it gives the same
set of error messages.

The debs are old. Install LLVM from source.

>> toy.cpp:5:30: error: llvm/LLVMContext.h: No such file or directory
>> toy.cpp:352: error: ‘getGlobalContext’ was not declared in this scope

This is new stuff in 2.6.

Right, it works with 2.6, thanks.