We have already made a article that shows how to install (after compiling) the Raylib library, but that procedure is with a dynamic library, but it is not suitable for using Raylib for the web.
So, in this post we will show you how to compile and install Raylib, in addition to being able to use it for desktop, also to use your development to run in the browser.
Dependencies
To use as a basis, we will focus on the Ubuntu operating system using APT, however, the procedure can be adapted to any other operating system, simply by finding the corresponding package names for your package manager and/or installation paths.
First, you must have the following packages properly installed on your system:
The session must have been started by X11, if it is on Wayland, end the session and log in again choosing Xorg.
Then, it is very important to have Emscripten installed, we show you how to do this in a video, but in short, just run these commands below:
After that, just run the command below and it will automatically open in your default browser:
Example running in the browser. Open the image in a new tab to see it in a higher resolution, if you want.
If you want to use the same code to run as a desktop, as you may already know, the command should be: g++ main.cpp -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 && ./a.out.
Remember that the example is without ASYNCIFY, for more information see here.