0

So I was running a C code in Notepad++ but it exited with the code: -1073741819. I don't know what this means and I cannot find any explanation online. Please tell me how to fix this problem.

Here is the full console log:

> Setup required Environment
-------------------------------------
SET: RAYLIB_PATH=C:\raylib\raylib
$(RAYLIB_PATH) = C:\raylib\raylib
SET: COMPILER_PATH=C:\raylib\mingw\bin
$(COMPILER_PATH) = C:\raylib\mingw\bin
ENV_SET: PATH=C:\raylib\mingw\bin
$(SYS.PATH) = C:\raylib\mingw\bin
SET: CC=gcc
$(CC) = gcc
SET: CFLAGS=$(RAYLIB_PATH)\src\raylib.rc.data -s -static -Os -std=c99 -Wall -I$(RAYLIB_PATH)\src -Iexternal -DPLATFORM_DESKTOP
$(CFLAGS) = C:\raylib\raylib\src\raylib.rc.data -s -static -Os -std=c99 -Wall -IC:\raylib\raylib\src -Iexternal -DPLATFORM_DESKTOP
SET: LDFLAGS=-lraylib -lopengl32 -lgdi32 -lwinmm
$(LDFLAGS) = -lraylib -lopengl32 -lgdi32 -lwinmm
CD: C:\raylib\raylib\examples\core
Current directory: C:\raylib\raylib\examples\core

> Clean latest build
------------------------
cmd /c IF EXIST core_basic_window.exe del /F core_basic_window.exe
Process started (PID=3288) >>>
<<< Process finished (PID=3288). (Exit code 0)

> Saving Current File
-------------------------
NPP_SAVE: C:\raylib\raylib\examples\core\core_basic_window.c

> Compile program
-----------------------
gcc -o core_basic_window.exe core_basic_window.c C:\raylib\raylib\src\raylib.rc.data -s -static -Os -std=c99 -Wall -IC:\raylib\raylib\src -Iexternal -DPLATFORM_DESKTOP -lraylib -lopengl32 -lgdi32 -lwinmm
Process started (PID=1924) >>>
<<< Process finished (PID=1924). (Exit code 0)

> Reset Environment
--------------------------
ENV_UNSET: PATH
$(SYS.PATH) has been restored

> Execute program
-----------------------
cmd /c IF EXIST core_basic_window.exe core_basic_window.exe
Process started (PID=3748) >>>
<<< Process finished (PID=3748). (Exit code -1073741819)
================ READY ================

Here is the code since a lot of people asked (I watched a tutorial to set up the library and they run the exact same code but it didn't work.):

#include "raylib.h"

int main(void)
{
    // Initialization
    //--------------------------------------------------------------------------------------
    const int screenWidth = 800;
    const int screenHeight = 450;

    InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window");

    SetTargetFPS(60);               // Set our game to run at 60 frames-per-second
    //--------------------------------------------------------------------------------------

    // Main game loop
    while (!WindowShouldClose())    // Detect window close button or ESC key
    {
        // Update
        //----------------------------------------------------------------------------------
        // TODO: Update your variables here
        //----------------------------------------------------------------------------------

        // Draw
        //----------------------------------------------------------------------------------
        BeginDrawing();

        ClearBackground(RAYWHITE);

        DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);

        EndDrawing();
        //----------------------------------------------------------------------------------
    }

    // De-Initialization
    //--------------------------------------------------------------------------------------
    CloseWindow();        // Close window and OpenGL context
    //--------------------------------------------------------------------------------------

    return 0;
}

This is what happens when I run it on Explorer and CMD window:

INFO: Initializing raylib 3.7
WARNING: GLFW: Error: 65543 Description: WGL: OpenGL profile requested but WGL_ARB_create_context_profile is unavailable
WARNING: GLFW: Failed to initialize Window
INFO: TIMER: Target time per frame: 16.667 milliseconds
4

1 回答 1

0

You can fix this by choosing your desired OpenGL version

You can achieve this by pressing F6, and on the right bottom corner there is a list, choose raylib_source_compile. And on line 4, choose the desired OpenGL version (GRAPHICS_API_OPENGL_33, GRAPHICS_API_OPENGL_21 and GRAPHICS_API_OPENGL_11) then press enter for it to recompile the Raylib library.

If it still doesnt work, go to C:\raylib\raylib\src\config.h, uncomment line 47 and recompile Raylib (which worked for me)

于 2021-06-12T11:59:23.370 回答