当前位置:网站首页>Self made compiler learning 1: use of CB compiler

Self made compiler learning 1: use of CB compiler

2022-06-09 08:25:00 I_ belong_ to_ jesus

Cb stay C The foundation of the language has been simplified , And add some new features , Thus, the production process of the compiler is simplified , First of all Cb Compiler installation , The use system is Ubuntu 16,Cb Compiler 64 A version of the git The website is : hGitHub - leungwensen/cbc-ubuntu-64bit: Cb (C flat) compiler. Cb is simplified C.s

First , Install dependency library :

apt-get update && apt-get install -y \
        gcc-multilib g++-multilib libc6-i386 lib32ncurses5 lib32stdc++6 \
        openjdk-8-jre \
        git

Download and install cbc:

git clone https://github.com/leungwensen/cbc-ubuntu-64bit.git
cd cbc-ubuntu-64bit && ./install.sh

compiler cbc Default installed in /usr/local/cbc/bin, Note that it is added to the environment variable PATH.

Create the first program file test_cb.cb:

import stdio;

int
main(int argc, char **argv)
{
printf("Hello World!\n");
return 0;
}

Execute compilation instructions ( Be careful 64 Bit system needs to be compatible 32 position ):

 cbc -Wa,"--32" -Wl,"-melf_i386" cbc_test.cb

After the compilation and execution are successful, there will be the following files in the folder :

They correspond to each other compile Generated Assembly language files :cbc_test.s, assembly Generated Target file cbc_test.o, as well as link Generated Executable file cbc_test.

原网站

版权声明
本文为[I_ belong_ to_ jesus]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/160/202206090812499804.html