2021-02-25 12:50:14 +01:00
# C kernel for Jupyter
This project was forked from [https://github.com/brendan-rius/jupyter-c-kernel ](brendan-rius/jupyter-c-kernel ) as that project seems to have been abandoned. (PR is pending)
This project includes fixes to many issues reported in [https://github.com/brendan-rius/jupyter-c-kernel ](brendan-rius/jupyter-c-kernel ), as well as the following additional features:
* Option for buffered output to mimic command line behaviour (useful for teaching, default is on)
* Command line input via `scanf` and `getchar`
* Support for `C89` /`ANSI C` (all newer versions were already supported and still are)
Following limitations compared to command line execution exist:
* Input is always buffered due to limitations of the jupyter interface
* When using `-ansi` or `-std=C89` , glibc still has to support at least `C99` for the interfacing with jupyter (this should not be an issue on an OS made after 2000)
2016-03-25 11:50:40 +00:00
2016-04-18 19:52:38 -07:00
## Use with Docker (recommended)
2016-03-26 15:39:37 +00:00
2021-02-25 12:50:14 +01:00
* `docker pull xaverklemenschits/jupyter-c-kernel`
* `docker run -p 8888:8888 xaverklemenschits/jupyter-c-kernel`
* Copy the given URL containing the token, and browse to it. For instance:
2020-03-22 12:52:45 +01:00
2021-02-25 12:50:14 +01:00
```bash
2017-08-10 14:00:51 -05:00
Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
http://localhost:8888/?token=66750c80bd0788f6ba15760aadz53beb9a9fb4cf8ac15ce8
```
2016-03-26 15:39:37 +00:00
2016-04-18 19:52:38 -07:00
## Manual installation
2017-08-13 16:25:27 +02:00
Works only on Linux and OS X. Windows is not supported yet. If you want to use this project on Windows, please use Docker.
2021-02-25 12:50:14 +01:00
* Make sure you have the following requirements installed:
2016-04-18 19:53:50 -07:00
* gcc
* jupyter
2016-04-30 11:13:20 +01:00
* python 3
2016-04-18 19:53:50 -07:00
* pip
2016-04-28 23:29:12 -03:00
2021-02-25 12:50:14 +01:00
### Step-by-step
2020-03-22 12:52:45 +01:00
```bash
git clone https://github.com/XaverKlemenschits/jupyter-c-kernel.git
cd jupyter-c-kernel
2020-05-08 15:53:37 +02:00
pip install -e . # for system install: sudo install .
cd jupyter_c_kernel & & install_c_kernel --user # for sys install: sudo install_c_kernel
2020-03-22 12:52:45 +01:00
# now you can start the notebook
jupyter notebook
```
2016-03-25 14:34:14 +00:00
## Example of notebook

2016-04-29 09:49:08 +01:00
2017-08-10 17:29:41 +02:00
## Custom compilation flags
You can use custom compilation flags like so:

Here, the `-lm` flag is passed so you can use the math library.
2016-04-30 21:44:41 +01:00
## Contributing
2016-06-08 11:29:29 +01:00
The docker image installs the kernel in editable mode, meaning that you can
change the code in real-time in Docker. For that, just run the docker box like
that:
```bash
2020-03-22 12:52:45 +01:00
git clone https://github.com/XaverKlemenschits/jupyter-c-kernel.git
2016-06-08 11:29:29 +01:00
cd jupyter-c-kernel
2020-03-22 12:52:45 +01:00
docker build -t myName/jupyter .
docker run -v $(pwd):/tmp/jupyter_c_kernel/ -p 8888:8888 myName/jupyter
2016-06-08 11:29:29 +01:00
```
This clones the source, run the kernel, and binds the current folder (the one
2017-08-10 14:00:51 -05:00
you just cloned) to the corresponding folder in Docker.
2016-06-08 11:29:29 +01:00
Now, if you change the source, it will be reflected in [http://localhost:8888 ](http://localhost:8888 )
instantly. Do not forget to click "restart" the kernel on the page as it does
not auto-restart.
2016-04-29 09:49:08 +01:00
## License
2016-06-06 15:52:40 +01:00
[MIT ](LICENSE.txt )