The 2025 Wheel Reinvention Jam just concluded. See the results.

Examples build errors on Windows with MinGW

I'm using MinGW 5.1 to build raylib, it went out smoothly with some warnings but building the examples throws this error:

1
2
3
4
5
6
C:\raylib\examples>mingw32-make PLATFORM=PLATFORM_DESKTOP
gcc -o core/core_basic_window core/core_basic_window.c -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces ../src/rayli
b.rc.data -Wl,--subsystem,windows -I. -I../src -I../src/external -L. -L../src -L../src -lraylib -lopengl32 -lgdi32 -lwin
mm -static -lpthread -DPLATFORM_DESKTOP
C:/MingW/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: 
i386 architecture of input file `../src/raylib.rc.data' is incompatible with i386:x86-64 output

Edited by BlitzCoder on
Hello BlitzCoder,

raylib.rc.data is just the resource file for icon and binary properties, you can remove that file from compilation line.

:)

Edited by Ray on
raysan5
Hello BlitzCoder,

raylib.rc.data is just the resource file for icon and binary properties, you can remove that file from compilation line.

:)


Hello Ray, I actually removed it and also stops with raylib.rc.data not found error
After wrestling with compiling the default `main.c` project that comes from `/raylib/projects/VSCode/` this was the post that finally made everything work! I decided to make an account and leave my two-cents in return.

Hopefully the OP @blitzcoder has long since figured-out his issues, but for those like me who are just starting out here is the solution that worked for me.

In the project-specific makefile, copied from the `/raylib/projects/VSCode/` starter-example, the file `raylib.rc.data` is added to the CFLAGS argument list.

Look here:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Additional flags for compiler (if desired)
#CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
    ifeq ($(PLATFORM_OS),WINDOWS)
        # resource file contains windows executable icon and properties
        # -Wl,--subsystem,windows hides the console window
        CFLAGS += $(RAYLIB_PATH)/src/raylib.rc.data -Wl,--subsystem,windows
    endif
    ifeq ($(PLATFORM_OS),LINUX)
        ifeq ($(RAYLIB_LIBTYPE),STATIC)
            CFLAGS += -D_DEFAULT_SOURCE
        endif
        ifeq ($(RAYLIB_LIBTYPE),SHARED)
            # Explicitly enable runtime link to libraylib.so
            CFLAGS += -Wl,-rpath,$(EXAMPLE_RUNTIME_PATH)
        endif
    endif
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
    CFLAGS += -std=gnu99
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
    #### ~ Trimmed for brevity ~
endif



I simply updated the line
1
CFLAGS += $(RAYLIB_PATH)/src/raylib.rc.data -Wl,--subsystem,windows

to
1
CFLAGS += -Wl,--subsystem,windows
.


For those who wish to know what is happening here the problem-file is a Windows Resource Compiler (.rc) file. It's compiled in such a way that our verson of compiler doesn't like. Visual Studio or the Microsoft Windows SDK will give you the 'rc' tool for compiling your own.
For more information see here:
https://docs.microsoft.com/en-us/...ws/win32/menurc/resource-compiler

For additional context I'm compiling everything with MinGW-m64:
http://mingw-w64.org/doku.php

I was trying anything to see what would stick, and while I was previously using the x86-64 (mingw64) set of tools/compilers I eventually ended-up getting a successful compile with the i686 option (mingw32). You can choose one or the other from the MinGW-m64 installer, and you can use it to install both if you wish. I don't think the specific version, mingw32 vs mingw64 would have mattered if I had just removed the CFLAGS reference earlier.

Thanks to the OP for the thread, and thanks to @raysan5 for the tip!
I just wanna say thank you for posting the solution. I struggled with this data.rc error for days, embarrassingly.

ah it's been a long time since.. I have yet to tinker with raylib and this issue again, but thank you @Spectron7x for posting a solution.


Edited by BlitzCoder on

For Raylib 4.2.0 examples Makefile comment with '#' the line: LDFLAGS += $(RAYLIB_PATH)/src/raylib.rc.data


Edited by grave on
Replying to Spectron7x (#22505)