Coursera compiler Set up environment and Run first program

Environment, Ubuntu 14.04

set up guide

 

Set up cool compiler

1. sudo apt-get install flex bison build-essential csh openjdk-6-jdk libxaw7-dev libc6-i386

2. Make the /usr/class directory

sudo mkdir /usr/class

3. Make the directory owned by you

sudo chown $USER /usr/class

4. Go to /usr/class and download the tarball

cd /usr/class

wget http://spark-university.s3.amazonaws.com/stanford-compilers/vm/student-dist.tar.gz

5. Untar

tar -xf student-dist.tar.gz

6. If you want things exactly like the VMs:

  Add a symlink to your home directory

  ln -s /usr/class/cs143/cool ~/cool

7. Add the bin directory to your $PATH environment variable. If you are using bash, add to your .profile (or .bash_profile, .bashrc etc. depending on your configuration; note that in Ubuntu have to log out and back in for this to take effect):

vim ~/.bashrc and append

PATH=/usr/class/cs143/cool/bin:$PATH

8. you may also need to do this

sudo apt-get install xfonts-75dpi xfonts-100dpi
xset +fp /usr/share/fonts/X11/75dpi

 

Run first program

$ mkdir examples
$ cd examples
$ cp /usr/class/cs143/examples/hello_world.cl .
$ coolc hello_world.cl
$ spim hello_world.s
SPIM Version 6.5 of January 4, 2003
Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu).
All Rights Reserved.
See the file README for a full copyright notice.
Loaded: /usr/class/cs143/cool/lib/trap.handler
Hello, World.
COOL program successfully executed
Stats -- #instructions : 152
         #reads : 27  #writes 22  #branches 28  #other 75

转载于:https://www.cnblogs.com/zhouzhuo/p/3758519.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值