Commit af840dd8 authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

Rewording.

parent 58a833c9
......@@ -31,7 +31,7 @@
"\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",
"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 writing of code.\n",
"\n",
"### Online compilers\n",
"\n",
......
%% Cell type:markdown id: tags:
# [Getting started in C++](/) - [How to do the TP](/notebooks/TP/HowTo.ipynb)
%% Cell type:markdown id: tags:
<h1>Table of contents<span class="tocSkip"></span></h1>
<div class="toc"><ul class="toc-item"><li><span><a href="#How-to-do-the-exercices?" data-toc-modified-id="How-to-do-the-exercices?-1">How to do the exercices?</a></span><ul class="toc-item"><li><span><a href="#Don't-do-the-TP-in-Jupyter-notebook!" data-toc-modified-id="Don't-do-the-TP-in-Jupyter-notebook!-1.1">Don't do the TP in Jupyter notebook!</a></span></li><li><span><a href="#Online-compilers" data-toc-modified-id="Online-compilers-1.2">Online compilers</a></span></li><li><span><a href="#On-your-local-machine" data-toc-modified-id="On-your-local-machine-1.3">On your local machine</a></span><ul class="toc-item"><li><span><a href="#How-to-compile-and-run-the-program?" data-toc-modified-id="How-to-compile-and-run-the-program?-1.3.1">How to compile and run the program?</a></span></li><li><span><a href="#For-each-exercice" data-toc-modified-id="For-each-exercice-1.3.2">For each exercice</a></span></li></ul></li><li><span><a href="#With-Docker" data-toc-modified-id="With-Docker-1.4">With Docker</a></span></li></ul></li></ul></div>
%% Cell type:markdown id: tags:
## How to do the exercices?
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.
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 writing 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 (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).
#### How to compile and run the program?
First create a folder in which the executables will be built and initialize CMake here:
````
mkdir -p build
cd build
cmake ..
````
Now in this folder you may run `make` to build the executables.
At first only `initial_file.cpp` is compiled into a `initial` executable.
You may run it through:
`./initial`
and if everything is allright you should see (in the case of the first TP 1-ProceduralProgramming):
````
0.65 ~ 1 / 2^1
0.65 ~ 3 / 2^2
0.65 ~ 5 / 2^3
````
Each time a change is made or a new file is added in `CMakeLists.txt`, you just need to run again `make` command.
#### For each exercice
The idea is to start from `initial_file.cpp` and modify it slightly in each exercice.
You need therefore to copy this file and create a new executable; you have basically two options:
* Using one file for all exercices in a given thematic. The pro is that you won't need to edit the CMakeLists.txt more than once, the con is that you don't keep the intermediate states of your work.
* Use a file per exercice; when beginning a new one you need to:
* Copy the former one into new cpp file, e.g. `cp exercice1.cpp exercice2.cpp`.
* Edit the CMakeLists.txt and uncomment the relevant line, e.g. `add_executable(exercice2 exercice2.cpp)`
I have done the latter but feel free to do the former if you wish.
### 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.
The steps to compile are the same as presented in the previous section.
For more informations about the Docker way please look the dedicated [README](https://gitlab.inria.fr/formations/cpp/gettingstartedwithmoderncpp/blob/master/TP/README.md) (the one within the TP folder of the root directory).
%% Cell type:markdown id: tags:
© _CNRS 2016_ - _Inria 2018-2019_
_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)_
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment