raylib 5.5 + PellesC v13.00.9 Tutorial
Hello World using precompiled raylib binaries (Windows, 32-bit)
What we are using in this tutorial (important)
For this tutorial, we are using this exact raylib package:
- `raylib-5.5_win32_msvc16.zip`
Notes:
- `5.5` = raylib version
- `win32` = 32-bit build
- `msvc16` = compiled with Microsoft Visual Studio toolchain
At the time this tutorial was written, this is the version/package tested for these steps.
Step 1 - Go to the raylib release page
Open the official raylib release page in your browser:
https://github.com/raysan5/raylib/releases
Find the release that contains this asset:
- `raylib-5.5_win32_msvc16.zip`
(For this tutorial, we are using the 5.5 release page.)
https://github.com/raysan5/raylib/releases/tag/5.5
Step 2 - Download the exact zip file
Download this file:
- `raylib-5.5_win32_msvc16.zip`
The file is listed near the bottom of the release page assets.
Note:
- Other precompiled packages/versions may also work.
- This tutorial was only tested with the package listed above.
Step 3 - Create a clean third-party folder (recommended)
If you do not already have a place to keep third-party DLLs/libs/headers, this works well:
- `C:\dev\3rdparty\raylib\`
For this tutorial, I assume this is where you put the files.
Step 4 - Extract the zip into a versioned folder
Extract `raylib-5.5_win32_msvc16.zip` into a versioned folder, for example:
- `C:\dev\3rdparty\raylib\raylib-5.5\`
Tip:
- Avoid accidental double nesting like:
- `C:\dev\3rdparty\raylib\raylib-5.5\raylib-5.5\...`
Step 5 - Create a project in PellesC IDE
For this example, create a Win32 Console Program named `raylib_pellesc_hello` in:
- `C:\dev\`
Create a `main.c` file with the following contents:
#include "raylib.h"
int main(void)
{
InitWindow(800, 450, "raylib hello");
SetTargetFPS(60);
while (!WindowShouldClose())
{
BeginDrawing();
ClearBackground(RAYWHITE);
DrawText("Hello, raylib!", 190, 200, 40, BLACK);
EndDrawing();
}
CloseWindow();
return 0;
}
Step 6 - Configure the project
Go to:
`Project -> Project Options`
Compiler
Click on `Compiler`:
* Change C Standard to `C17`
* Enable `Microsoft Extensions`
Folders
Click `General -> Folders`
Notice the dropdown next to `Type` (it may default to `Libraries`).
With `Type = Libraries`, add:
`C:\dev\3rdparty\raylib\raylib-5.5\lib`
Change dropdown to `Includes`, then add:
`C:\dev\3rdparty\raylib\raylib-5.5\include`
Linker
Click on `Linker`
Under `Library and object files`, include:
`kernel32.lib advapi32.lib delayimp.lib raylibdll.lib opengl32.lib gdi32.lib winmm.lib user32.lib shell32.lib`
Important:
Repeat Step 6 for each build target you plan to use (`Debug` / `Release`).
Step 7 - Build and Run
Build and run using PellesC.
- Copy the raylib.dll found in C:\dev\3rdparty\raylib\raylib-5.5\lib to the root of the project. The exe built by the compiler should reside next to the copied dll.
- `ESC` will close the program.
If everything is configured correctly, you should see a raylib window with:
`Hello, raylib!`
Runtime note (important if build works but program will not start)
Because this tutorial links against `raylibdll.lib`, you will also need `raylib.dll` available at runtime.
Common fix:
Copy `raylib.dll` into the same folder as your compiled `.exe`
If the program builds but fails to start, this is one of the first things to check.
Final note
Let me know if I missed anything and I will update the steps.
If your extracted folder layout is different, post the folder names/files and we can adjust the tutorial.
Those libraries needs a RAD environment too to survive.
Just think what happened to Borland RADs.
Small programs are easy to develop with basic Win32 GUI.
TLPeView have a bit an experiment GUI, that many don't like it.
But with free source, people can make a basic GUI too or what ever they want.
Only internal functions are important, as those needs improvements.
Like resource section handling.
TLPEView is a just blackbox clone of Wayne J. Radburn excellent PEView for 32-bit files.
Wayne have full TLPEView sources how checking binary parsers was made for x64 too.
Hello rweidner,
Thanks for the sample, I managed to build it. The problem is the serious name conflicts if one needs to use the master Windows header file windows.h :
Building raylibDemo.obj.
E:\PellesC\raylibDemo\raylib.h(260): error #2119: Redeclaration of 'Rectangle', previously declared at E:\PellesC\Include\Win\wingdi.h(3938).
E:\PellesC\raylibDemo\raylib.h(969): error #2119: Redeclaration of 'CloseWindow', previously declared at E:\PellesC\Include\Win\winuser.h(3561).
E:\PellesC\raylibDemo\raylib.h(1019): error #2119: Redeclaration of 'ShowCursor', previously declared at E:\PellesC\Include\Win\winuser.h(6875).
E:\PellesC\raylibDemo\raylib.h(1323): error #2119: Redeclaration of 'LoadImageA', previously declared at E:\PellesC\Include\Win\winuser.h(7950).
E:\PellesC\raylibDemo\raylib.h(1474): error #2119: Redeclaration of 'DrawTextA', previously declared at E:\PellesC\Include\Win\winuser.h(6099).
E:\PellesC\raylibDemo\raylib.h(1475): error #2119: Redeclaration of 'DrawTextExA', previously declared at E:\PellesC\Include\Win\winuser.h(6119).
E:\PellesC\raylibDemo\raylib.h(1649): error #2119: Redeclaration of 'PlaySoundA', previously declared at E:\PellesC\Include\Win\playsoundapi.h(64).
*** Error code: 1 ***
Done.
Wow, Vortex. That is an interesting problem. I'll look at this more closely. I might have run into this too, sooner or later. What's interesting is that if you look at the raylib.h file on lines 1323, 1475, 1476, and 1649, raylib didn't define LoadImageA, DrawTextA, DrawTextExA, or PlaySoundA. This smells like some macro voodoo to me.
Question: For whatever reason it was that you included windows.h is it necessary that windows.h is included in the same file as raylib.h? Would a separate .c file help so that raylib.h and windows.h are not included in the same file?
Hi rweidner,
The reason is simple. If you wish to build a "standard" GUI application, you need the specify the WinMain function instead of main :
#include "raylib.h"
#include <windows.h>
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
InitWindow(800, 450, "raylib hello");
SetTargetFPS(60);
while (!WindowShouldClose())
{
BeginDrawing();
ClearBackground(RAYWHITE);
DrawText("Hello, raylib!", 190, 200, 40, BLACK);
EndDrawing();
}
CloseWindow();
return 0;
}
Here are some links for you to check the issue :
https://github.com/raysan5/raylib/issues/2806
https://github.com/raysan5/raylib/issues/1217
https://raylib.handmade.network/forums/t/7294-raylib_and_winmain
https://www.reddit.com/r/raylib/comments/vnnha0/how_do_i_prevent_the_console_from_opening_on_all/
https://keasigmadelta.com/blog/raylib-hide-the-console-window-on-windows-release-builds/?srsltid=AfmBOorcOL85hkGTczvcJKJe9SH9kLlUMKWtaLq7DNnO2Z6Wjoq5O3ms
Here is a solution, possibly. There are 2 "tricks" to making this work.
1. Never include windows.h in the same file where raylib.h is included also. The example below demonstrates.
2. Project -> Project Options. Under Compiler click Code generation. Change "Default calling Convention" to __cdecl
Now I'm building an Win32 app. Notice in the code there isn't a int main(void) function. Does this help?
//File: game_main.h
#ifndef GAME_MAIN_H
#define GAME_MAIN_H
int GameMain(void);
#endif
//File: main.c
#include "game_main.h"
#include <windows.h>
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
return GameMain();
}
// File: game_main.c
#include "game_main.h"
#include "raylib.h"
int GameMain(void)
{
InitWindow(800, 450, "raylib hello");
SetTargetFPS(60);
while (!WindowShouldClose())
{
BeginDrawing();
ClearBackground(RAYWHITE);
DrawText("Hello, raylib!", 190, 200, 40, BLACK);
EndDrawing();
}
CloseWindow();
return 0;
}