Skip to content

Latest commit

 

History

History
187 lines (112 loc) · 6.03 KB

COMPILING.md

File metadata and controls

187 lines (112 loc) · 6.03 KB

Compiling and running

This project uses CMake to generate the build tools required to compile the code into an executable binary file bin/myexec. CMake can create a Makefile or a project file for you favorite IDE.

We will call CMake in a directory called build, where all the compilation files and IDE-related stuff will be. The project itself, which is contained in the src and deps folders will stay clean. If you have any issue with the procedure explained below, just remove everything in the build directory and try again !


on Ubuntu

Learning to use the terminal !

If you don't know how to use a terminal, how to change directories within a terminal etc. see the tutorial on using the terminal

Installing dependencies:

sudo apt-get install cmake xorg-dev libglu1-mesa-dev

Optionally, you can also install cmake-qt-gui or cmake-curses-gui for a graphical user interface (GUI) to CMake. You will then use cmake-gui or ccmake instead of cmake to use the GUI.

Compiling:

  1. Create the Makefile (do this only once):

    mkdir build   # Creates the build directory
    cd build      # Go into the build directory
    cmake ..      # Call CMake with the top-level directory as argument (`..` is the parent directory)
    

    Instead of using cmake .. to generate a Makefile, you can also build project for Visual Studio, XCode, Sublime-Text, CodeBlocks, Eclipse... using cmake -G GENERATOR_NAME .. . Available generators are listed with cmake --help

    Alternatively, if you installed a CMake GUI, you can also follow the part of the windows instruction concerning CMake, which basically work the same.

  2. Compile the program into an executable (do this every time you changed a file)* :

     make
    

    *If you created a project file for an IDE instead of a makefile (if you used cmake -G GENERATOR_NAME ..), this step will not work. Normally, in an IDE, running the project will automatically compiles the code.

Running:

Again, if you are not using an IDE:

./bin/myexec

on MacOS

Learning to use the terminal !

If you don't know how to use a terminal, how to change directories within a terminal etc. see the tutorial on using the terminal

Installing dependencies:

  1. Install XCode
  2. Install CMake

Compiling:

  1. Create the Makefile (do this only once):

    mkdir build   # Creates the build directory
    cd build      # Go into the build directory
    cmake ..      # Call CMake with the top-level directory as argument (`..` is the parent directory)
    

    Instead of using cmake .. to generate a Makefile, you can also build project for Visual Studio, XCode, Sublime-Text, CodeBlocks, Eclipse... using cmake -G GENERATOR_NAME .. . Available generators are listed with cmake --help

  2. Compile the program into an executable (do this every time you changed a file)* :

    make
    

    *If you created a project file for an IDE instead of a makefile (if you used cmake -G GENERATOR_NAME ..), this step will not work. Normally, in an IDE, running the project will automatically compiles the code.

Running:

Again, if you are not using an IDE:

./bin/myexec

on Windows

Installing dependencies:

Creating a Visual Studio Project using CMake:

If you are familiar with CMake this should be straightforward

  1. Create a directory named "build" in the top-level directory (the one containing src, deps, doc and build)

  2. Launch CMake GUI (type: Win+S, "cmake-gui", Enter)

  3. For the source code location, select the top-level directory

  4. For the binaries location, select the build directory

  5. Click the "Configure" button, a pop-up window will appear:

    • Optionnally select you version of Visual Studio and Win64 if your computer support 64-bit
    • Click on the "Finish" button
    • WAIT ! it can take several minutes...
    • Do not worry about the red content.

  6. Click the "Generate" button

  7. Click the "Open Project" button

Compiling the project in Visual Studio:

Ctrl+Maj+B

or in the above menu, click on "Build -> Build Solution". In french GUI: "Générer -> Générer la Solution"

Running the project in Visual Studio:

Ctrl+f5

or in the above menu, click on "Debug -> Start Debugging" In french GUI: "Déboguer -> Exécuter sans Débogage"