mirror of https://github.com/aamine/cbc
finishing document and bugfixes, etc.
This commit is contained in:
parent
9891753df3
commit
d7334530be
55
README.md
55
README.md
|
|
@ -1,12 +1,14 @@
|
|||
CbC - Cflat Compiler (the ubuntu 64bit version)
|
||||
====================
|
||||
|
||||
[《自制编译器》](http://www.ituring.com.cn/book/1308)一书中实现的cbc编译器的ubuntu64位版本。
|
||||
[《自制编译器》](http://www.ituring.com.cn/book/1308)一书中实现的cbc编译器的ubuntu64位版本。这个项目主要解决64位机器上无法正常编译和运行[cbc](https://github.com/aamine/cbc)的问题。
|
||||
|
||||
## 用法(在ubuntu 64位系统上)
|
||||
## 直接安装使用(在ubuntu 64位系统上)
|
||||
|
||||
### 安装依赖
|
||||
|
||||
> 注意:不同ubuntu发行版可能依赖库名称不一致。此处代码为ubuntu 16.04版本上的安装命令
|
||||
|
||||
```shell
|
||||
apt-get update && apt-get install -y \
|
||||
gcc-multilib g++-multilib libc6-i386 lib32ncurses5 lib32stdc++6 \
|
||||
|
|
@ -14,12 +16,11 @@ apt-get update && apt-get install -y \
|
|||
git
|
||||
```
|
||||
|
||||
### 下载&安装
|
||||
### 下载&安装cbc
|
||||
|
||||
```shell
|
||||
git clone https://github.com/leungwensen/cbc-ubuntu-64bit.git
|
||||
cd cbc-ubuntu-64bit
|
||||
./install.sh
|
||||
cd cbc-ubuntu-64bit && ./install.sh
|
||||
```
|
||||
|
||||
### 使用
|
||||
|
|
@ -27,12 +28,48 @@ cd cbc-ubuntu-64bit
|
|||
和原始的cbc不同,在64位系统里需要增加`-Wa,"--32" -Wl,"-melf_i386"`执行参数。
|
||||
|
||||
```shell
|
||||
$ cbc -Wa,"--32" -Wl,"-melf_i386" test/hello.cb
|
||||
$ ./hello
|
||||
Hello, World!
|
||||
cbc -Wa,"--32" -Wl,"-melf_i386" test/hello.cb
|
||||
./hello
|
||||
> Hello, World!
|
||||
```
|
||||
|
||||
## docker镜像
|
||||
## 使用docker镜像(在任意64位宿主环境上)
|
||||
|
||||
大致的原理就是基于ubuntu 16.04的64位系统构建了一个可供cbc编译、执行的环境。用户只需把打包好的镜像下载到本地就可以得到可执行的cbc,免去配置和编译cbc的麻烦。
|
||||
|
||||
### 安装docker:详见[Docker 中文指南](http://docker.widuu.com/index.html)
|
||||
|
||||
### 启动docker daemon进程
|
||||
|
||||
```shell
|
||||
eval $(docker-machine env default)
|
||||
```
|
||||
|
||||
### 下载镜像
|
||||
|
||||
```shell
|
||||
docker pull leungwensen/cbc-ubuntu-64bit
|
||||
```
|
||||
|
||||
### 执行镜像
|
||||
|
||||
```shell
|
||||
docker run -t -i leungwensen/cbc-ubuntu-64bit
|
||||
```
|
||||
|
||||
### 执行cbc
|
||||
|
||||
> 镜像里的cbc命令为`cbc -Wa,--32 -Wl,-melf_i386`的别名,可以直接执行。
|
||||
|
||||
```shell
|
||||
cbc cbc-ubuntu-64bit/test/hello.cb
|
||||
```
|
||||
|
||||
## 共建/bug报告
|
||||
|
||||
有任何使用上的问题,可以[搜索已有issue或者新建一个issue](https://github.com/leungwensen/cbc-ubuntu-64bit/issues)。
|
||||
|
||||
更希望大家可以一起完善这个项目,给我提[pull request](https://github.com/leungwensen/cbc-ubuntu-64bit/pulls)
|
||||
|
||||
## 参考
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ RUN cd cbc-ubuntu-64bit && bash install.sh
|
|||
|
||||
RUN echo 'PATH=/usr/local/cbc/bin:$PATH' >> $HOME/.bashrc
|
||||
|
||||
RUN echo alias cbc=cbc -Wa,--32 -Wl,-melf_i386 >> $HOME/.bashrc
|
||||
RUN echo alias cbc='cbc -Wa,--32 -Wl,-melf_i386' >> $HOME/.bashrc
|
||||
|
||||
# commands when creating a new container
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue