Skip to content

Update "Building for Linux" #104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: gh-pages
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 18 additions & 19 deletions beginners-tutorials/tutorial-1-opening-a-window/index.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -83,33 +83,32 @@ You can also launch any tutorial from inside Visual Studio. Right-click on Playg

## Building on Linux

They are so many Linux variants out there that it's impossible to list every possible platform. Adapt if required, and don't hesitate to read your distribution's documentation.


There are so many Linux variants out there that it's impossible to list every possible platform. Adapt if required, and don't hesitate to read your distribution's documentation.

* Install the latest drivers. We highly recommend the closed-source binary drivers. It's not GNU or whatever, but they work. If your distribution doesn't provide an automatic install, try [Ubuntu's guide](http://help.ubuntu.com/community/BinaryDriverHowto).
* Install all needed compilers, tools & libs. Complete list is : *cmake make g++ libx11-dev libxi-dev libgl1-mesa-dev libglu1-mesa-dev libxrandr-dev libxext-dev libxcursor-dev libxinerama-dev libxi-dev* . Use `sudo apt-get install *****` or `su && yum install ******`.
* Install all needed compilers, tools & libs:
* On Ubuntu, use `sudo apt install cmake make g++ libx11-dev libxi-dev libgl1-mesa-dev libglu1-mesa-dev libxrandr-dev libxext-dev libxcursor-dev libxinerama-dev libxi-dev`.
* On Fedora, use `sudo dnf install cmake make g++ libX11-devel libXi-devel mesa-libGLU-devel mesa-libGL-devel libXrandr-devel libXext-devel libXcursor-devel libXinerama-devel libXi-devel`.
* [Download the source code](http://www.opengl-tutorial.org/download/) and unzip it, for instance in ~/Projects/OpenGLTutorials/
* cd in ~/Projects/OpenGLTutorials/ and enter the following commands :

* mkdir build
* cd build
* cmake ..


* A makefile has been created in the build/ directory.
* type "make all". Every tutorial and dependency will be compiled. Each executable will also be copied back into ~/Projects/OpenGLTutorials/ . Hopefuly no error occurs.
* Open ~/Projects/OpenGLTutorials/playground, and launch ./playground. A black window should appear.
* cd in ~/Projects/OpenGLTutorials/ and enter the following commands:
```bash
mkdir build
cd build
cmake ..
```
* A makefile has been created in the `build/` directory.
* type `make all`. Every tutorial and dependency will be compiled. Each executable will also be copied back into `~/Projects/OpenGLTutorials/` . Hopefully no error occurs.
* Open `~/Projects/OpenGLTutorials/playground`, and launch `./playground`. A black window should appear.

Note that you really should use an IDE like [Qt Creator](http://qt-project.org/). In particular, this one has built-in support for CMake, and it will provide a much nicer experience when debugging. Here are the instructions for QtCreator :

* In QtCreator, go to File->Tools->Options->Compile&Execute->CMake
* Set the path to CMake. This is most probably /usr/bin/cmake
* File->Open Project; Select tutorials/CMakeLists.txt
* Set the path to CMake. This is most probably `/usr/bin/cmake`
* File->Open Project; Select `tutorials/CMakeLists.txt`
* Select a build directory, preferably outside the tutorials folder
* Optionally set -DCMAKE_BUILD_TYPE=Debug in the parameters box. Validate.
* Click on the hammer on the bottom. The tutorials can now be launched from the tutorials/ folder.
* To run the tutorials from QtCreator, click on Projects->Execution parameters->Working Directory, and select the directory where the shaders, textures & models live. Example for tutorial 2 : ~/opengl-tutorial/tutorial02_red_triangle/
* Optionally set `-DCMAKE_BUILD_TYPE=Debug` in the parameters box. Validate.
* Click on the hammer on the bottom. The tutorials can now be launched from the `tutorials/` folder.
* To run the tutorials from QtCreator, click on Projects->Execution parameters->Working Directory, and select the directory where the shaders, textures & models live. Example for tutorial 2 : `~/opengl-tutorial/tutorial02_red_triangle/`


## Building on Mac
Expand Down