"# [Getting started in C++](/) - [How to do the TP](/notebooks/TP/HowTo.ipynb)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Introduction\n",
"\n",
"TPs are interspeded throughout the lecture, and are really recommended as it is a way to check you truly assimilated what was explained in the notebooks (in programming rather often things seem easy... until you try to do them by yourself!)\n",
"\n",
"There are basically three ways to do the exercices, but I will start with the one to avoid:\n",
"\n",
"### Don't do the TP in Jupyter notebook!\n",
"\n",
"Jupyter notebooks are a great tool to provide a decent and interactive support for lectures, and we can really thank the [guys behind Xeus-cling](https://github.com/QuantStack/xeus-cling/graphs/contributors) for their amazing work to port C++ into an interpreter-like environment.\n",
"\n",
"However, it is clearly not an environment for direct development: the fact you need to restart the kernel and rerun all relevant cells each time you modify a function is extremely cumbersome during the trial-and-error that is often the implementation of code.\n",
"\n",
"### Online compilers\n",
"\n",
"[Coliru](https://coliru.stacked-crooked.com/) or [Wandbox](https://wandbox.org/) provides online compilers in which you may paste code, compile it and then run it.\n",
"\n",
"They are clearly the easiest way to go that we recommend heavily! (except for the [TP related to file structure](/notebooks/6-InRealEnvironment/2-b-TP.ipynb) for which we will need to work locally). \n",
"\n",
"### On your local machine\n",
"\n",
"This implies a _recent_ compiler is already installed on your machine and ready to use.\n",
"\n",
"I provide in the folder in which TPs are set a very basic and crude `CMakeLists.txt` that should provide compilation (at least on Unix systems).\n",
"\n",
"### With Docker\n",
"\n",
"I also provide a [Docker](https://www.docker.com/) image in which a very basic Fedora environment is displayed.\n",
"\n",
"You may compile / run the code in a Docker container and edit your file in your computer environment with you favored editor / IDE. \n",
"\n",
"For more informations about it please look the dedicated [README](https://gitlab.inria.fr/formations/cpp/gettingstartedwithmoderncpp/blob/master/TP/README.md).\n"
"_This notebook is an adaptation of a lecture prepared and redacted by David Chamont (CNRS) under the terms of the licence [Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)](http://creativecommons.org/licenses/by-nc-sa/4.0/)_ \n",
"_The present version has been redacted by Sébastien Gilles and Vincent Rouvreau (Inria)_"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "C++17",
"language": "C++17",
"name": "xeus-cling-cpp17"
},
"language_info": {
"codemirror_mode": "text/x-c++src",
"file_extension": ".cpp",
"mimetype": "text/x-c++src",
"name": "c++",
"version": "-std=c++17"
},
"latex_envs": {
"LaTeX_envs_menu_present": true,
"autoclose": false,
"autocomplete": true,
"bibliofile": "biblio.bib",
"cite_by": "apalike",
"current_citInitial": 1,
"eqLabelWithNumbers": true,
"eqNumInitial": 1,
"hotkeys": {
"equation": "Ctrl-E",
"itemize": "Ctrl-I"
},
"labels_anchors": false,
"latex_user_defs": false,
"report_style_numbering": false,
"user_envs_cfg": false
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": false,
"sideBar": true,
"skip_h1_title": true,
"title_cell": "Table of contents",
"title_sidebar": "Table of contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": true
}
},
"nbformat": 4,
"nbformat_minor": 2
}
%% Cell type:markdown id: tags:
# [Getting started in C++](/) - [How to do the TP](/notebooks/TP/HowTo.ipynb)
%% Cell type:markdown id: tags:
## Introduction
TPs are interspeded throughout the lecture, and are really recommended as it is a way to check you truly assimilated what was explained in the notebooks (in programming rather often things seem easy... until you try to do them by yourself!)
There are basically three ways to do the exercices, but I will start with the one to avoid:
### Don't do the TP in Jupyter notebook!
Jupyter notebooks are a great tool to provide a decent and interactive support for lectures, and we can really thank the [guys behind Xeus-cling](https://github.com/QuantStack/xeus-cling/graphs/contributors) for their amazing work to port C++ into an interpreter-like environment.
However, it is clearly not an environment for direct development: the fact you need to restart the kernel and rerun all relevant cells each time you modify a function is extremely cumbersome during the trial-and-error that is often the implementation of code.
### Online compilers
[Coliru](https://coliru.stacked-crooked.com/) or [Wandbox](https://wandbox.org/) provides online compilers in which you may paste code, compile it and then run it.
They are clearly the easiest way to go that we recommend heavily! (except for the [TP related to file structure](/notebooks/6-InRealEnvironment/2-b-TP.ipynb) for which we will need to work locally).
### On your local machine
This implies a _recent_ compiler is already installed on your machine and ready to use.
I provide in the folder in which TPs are set a very basic and crude `CMakeLists.txt` that should provide compilation (at least on Unix systems).
### With Docker
I also provide a [Docker](https://www.docker.com/) image in which a very basic Fedora environment is displayed.
You may compile / run the code in a Docker container and edit your file in your computer environment with you favored editor / IDE.
For more informations about it please look the dedicated [README](https://gitlab.inria.fr/formations/cpp/gettingstartedwithmoderncpp/blob/master/TP/README.md).
_This notebook is an adaptation of a lecture prepared and redacted by David Chamont (CNRS) under the terms of the licence [Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)](http://creativecommons.org/licenses/by-nc-sa/4.0/)_
_The present version has been redacted by Sébastien Gilles and Vincent Rouvreau (Inria)_
Go in the _Docker/ThirdPartyWarning_ folder and type:
Go in the TP folder of the current TP considered (for instance `1-ProceduralProgramming/TP`) and type:
````
````
docker run -v $PWD:/Codes/TP --cap-drop=all -it tp_cpp
docker run -v $PWD:/Codes/TP --cap-drop=all -it tp
````
````
For those of you not familiar with Docker:
For those of you not familiar with Docker:
...
@@ -39,5 +39,5 @@ For those of you not familiar with Docker:
...
@@ -39,5 +39,5 @@ For those of you not familiar with Docker:
*`--cap-drop=all` is a safety when you're running a Docker image not built by yourself: you're essentially blocking the few remaining operations that might impact your own environment that Docker lets by default open with the run command.
*`--cap-drop=all` is a safety when you're running a Docker image not built by yourself: you're essentially blocking the few remaining operations that might impact your own environment that Docker lets by default open with the run command.
*`-it` tells we want an interactive session: your terminal session will place you inside the container (here a Fedora environment).
*`-it` tells we want an interactive session: your terminal session will place you inside the container (here a Fedora environment).
`tp_cpp` is a Docker **image**; the instantiation of this image obtained after the run command is a **container**. All the modifications you may do in the container won't be kept when you leave it, except the files that will have been written in your own filesystem thanks to the `-v` option.
`tp` is a Docker **image**; the instantiation of this image obtained after the run command is a **container**. All the modifications you may do in the container won't be kept when you leave it, except for the files that will have been written in your own filesystem thanks to the `-v` option.