Skip to content
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

[build] Issue And Solution : RayLib 2.5 programs doesn't compile on windows (Visual Studio 2017) #896

Closed
MahmoudFayed opened this issue Jun 23, 2019 · 2 comments

Comments

@MahmoudFayed
Copy link

MahmoudFayed commented Jun 23, 2019

Hello

RayLib is a nice library, It's powerful and simple, I decided to integrate it with the Ring programming language (http://ring-lang.net - To be distributed with the language as one of the standard libraries)
I tried to use the RayLib 2.5 (binary release) for Microsoft Windows, using Visual Studio 2017 (Command Prompt), but I get the next Syntax Errors !

**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.4.0
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
Microsoft (R) C/C++ Optimizing Compiler Version 19.11.25547 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

ring_raylib.c
..\..\libdepwin\raylib2.5\include\raylib.h(214): error C2365: 'Rectangle': redefinition; previous definition was 'function'
C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\wingdi.h(4498): note: see declaration of 'Rectangle'
..\..\libdepwin\raylib2.5\include\raylib.h(255): error C2061: syntax error: identifier 'Rectangle'
..\..\libdepwin\raylib2.5\include\raylib.h(261): error C2059: syntax error: '}'
..\..\libdepwin\raylib2.5\include\raylib.h(266): error C2061: syntax error: identifier 'Rectangle'
..\..\libdepwin\raylib2.5\include\raylib.h(271): error C2059: syntax error: '}'
..\..\libdepwin\raylib2.5\include\raylib.h(278): error C2061: syntax error: identifier 'CharInfo'
..\..\libdepwin\raylib2.5\include\raylib.h(279): error C2059: syntax error: '}'
..\..\libdepwin\raylib2.5\include\raylib.h(863): error C2373: 'CloseWindow': redefinition; different type modifiers
C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winuser.h(4593): note: see declaration of 'CloseWindow'
..\..\libdepwin\raylib2.5\include\raylib.h(890): error C2373: 'ShowCursor': redefinition; different type modifiers
C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winuser.h(9082): note: see declaration of 'ShowCursor'
..\..\libdepwin\raylib2.5\include\raylib.h(1045): error C2146: syntax error: missing ')' before identifier 'rec'
..\..\libdepwin\raylib2.5\include\raylib.h(1045): error C2061: syntax error: identifier 'rec'
..\..\libdepwin\raylib2.5\include\raylib.h(1045): error C2059: syntax error: ';'
..\..\libdepwin\raylib2.5\include\raylib.h(1045): error C2059: syntax error: ','
..\..\libdepwin\raylib2.5\include\raylib.h(1045): error C2059: syntax error: ')'
..\..\libdepwin\raylib2.5\include\raylib.h(1046): error C2146: syntax error: missing ')' before identifier 'rec'
..\..\libdepwin\raylib2.5\include\raylib.h(1046): error C2061: syntax error: identifier 'rec'
..\..\libdepwin\raylib2.5\include\raylib.h(1046): error C2059: syntax error: ';'
..\..\libdepwin\raylib2.5\include\raylib.h(1046): error C2059: syntax error: ','
..\..\libdepwin\raylib2.5\include\raylib.h(1046): error C2059: syntax error: ')'
..\..\libdepwin\raylib2.5\include\raylib.h(1049): error C2146: syntax error: missing ')' before identifier 'rec'
..\..\libdepwin\raylib2.5\include\raylib.h(1049): error C2061: syntax error: identifier 'rec'
..\..\libdepwin\raylib2.5\include\raylib.h(1049): error C2059: syntax error: ';'
..\..\libdepwin\raylib2.5\include\raylib.h(1049): error C2059: syntax error: ','
..\..\libdepwin\raylib2.5\include\raylib.h(1049): error C2059: syntax error: ')'
..\..\libdepwin\raylib2.5\include\raylib.h(1051): error C2146: syntax error: missing ')' before identifier 'rec'
..\..\libdepwin\raylib2.5\include\raylib.h(1051): error C2061: syntax error: identifier 'rec'
..\..\libdepwin\raylib2.5\include\raylib.h(1051): error C2059: syntax error: ';'
..\..\libdepwin\raylib2.5\include\raylib.h(1051): error C2059: syntax error: ','
..\..\libdepwin\raylib2.5\include\raylib.h(1051): error C2059: syntax error: ')'
..\..\libdepwin\raylib2.5\include\raylib.h(1052): error C2146: syntax error: missing ')' before identifier 'rec'
..\..\libdepwin\raylib2.5\include\raylib.h(1052): error C2061: syntax error: identifier 'rec'
..\..\libdepwin\raylib2.5\include\raylib.h(1052): error C2059: syntax error: ';'
..\..\libdepwin\raylib2.5\include\raylib.h(1052): error C2059: syntax error: ','
..\..\libdepwin\raylib2.5\include\raylib.h(1052): error C2059: syntax error: ')'
..\..\libdepwin\raylib2.5\include\raylib.h(1053): error C2146: syntax error: missing ')' before identifier 'rec'
..\..\libdepwin\raylib2.5\include\raylib.h(1053): error C2061: syntax error: identifier 'rec'
..\..\libdepwin\raylib2.5\include\raylib.h(1053): error C2059: syntax error: ';'
..\..\libdepwin\raylib2.5\include\raylib.h(1053): error C2059: syntax error: ','
..\..\libdepwin\raylib2.5\include\raylib.h(1053): error C2059: syntax error: ')'
..\..\libdepwin\raylib2.5\include\raylib.h(1059): error C2146: syntax error: missing ')' before identifier 'source'
..\..\libdepwin\raylib2.5\include\raylib.h(1059): error C2081: 'Rectangle': name in formal parameter list illegal
..\..\libdepwin\raylib2.5\include\raylib.h(1059): error C2061: syntax error: identifier 'source'
..\..\libdepwin\raylib2.5\include\raylib.h(1059): error C2059: syntax error: ';'
..\..\libdepwin\raylib2.5\include\raylib.h(1059): error C2059: syntax error: ')'
..\..\libdepwin\raylib2.5\include\raylib.h(1062): error C2146: syntax error: missing ')' before identifier 'rec1'
..\..\libdepwin\raylib2.5\include\raylib.h(1062): error C2061: syntax error: identifier 'rec1'
..\..\libdepwin\raylib2.5\include\raylib.h(1062): error C2059: syntax error: ';'
..\..\libdepwin\raylib2.5\include\raylib.h(1062): error C2059: syntax error: ','
..\..\libdepwin\raylib2.5\include\raylib.h(1062): error C2059: syntax error: ')'
..\..\libdepwin\raylib2.5\include\raylib.h(1064): error C2146: syntax error: missing ')' before identifier 'rec'
..\..\libdepwin\raylib2.5\include\raylib.h(1064): error C2081: 'Rectangle': name in formal parameter list illegal
..\..\libdepwin\raylib2.5\include\raylib.h(1064): error C2061: syntax error: identifier 'rec'
..\..\libdepwin\raylib2.5\include\raylib.h(1064): error C2059: syntax error: ';'
..\..\libdepwin\raylib2.5\include\raylib.h(1064): error C2059: syntax error: ')'
..\..\libdepwin\raylib2.5\include\raylib.h(1065): error C2061: syntax error: identifier 'GetCollisionRec'
..\..\libdepwin\raylib2.5\include\raylib.h(1065): error C2059: syntax error: ';'
..\..\libdepwin\raylib2.5\include\raylib.h(1065): error C2146: syntax error: missing ')' before identifier 'rec1'
..\..\libdepwin\raylib2.5\include\raylib.h(1065): error C2061: syntax error: identifier 'rec1'
..\..\libdepwin\raylib2.5\include\raylib.h(1065): error C2059: syntax error: ','
..\..\libdepwin\raylib2.5\include\raylib.h(1065): error C2059: syntax error: ')'
..\..\libdepwin\raylib2.5\include\raylib.h(1066): error C2146: syntax error: missing ')' before identifier 'rec'
..\..\libdepwin\raylib2.5\include\raylib.h(1066): error C2081: 'Rectangle': name in formal parameter list illegal
..\..\libdepwin\raylib2.5\include\raylib.h(1066): error C2061: syntax error: identifier 'rec'
..\..\libdepwin\raylib2.5\include\raylib.h(1066): error C2059: syntax error: ';'
..\..\libdepwin\raylib2.5\include\raylib.h(1066): error C2059: syntax error: ')'
..\..\libdepwin\raylib2.5\include\raylib.h(1075): error C2373: 'LoadImageA': redefinition; different type modifiers
C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winuser.h(10513): note: see declaration of 'LoadImageA'
..\..\libdepwin\raylib2.5\include\raylib.h(1103): error C2146: syntax error: missing ')' before identifier 'crop'
..\..\libdepwin\raylib2.5\include\raylib.h(1103): error C2081: 'Rectangle': name in formal parameter list illegal
..\..\libdepwin\raylib2.5\include\raylib.h(1103): error C2061: syntax error: identifier 'crop'
..\..\libdepwin\raylib2.5\include\raylib.h(1103): error C2059: syntax error: ';'
..\..\libdepwin\raylib2.5\include\raylib.h(1103): error C2059: syntax error: ')'
..\..\libdepwin\raylib2.5\include\raylib.h(1111): error C2146: syntax error: missing ')' before identifier 'font'
..\..\libdepwin\raylib2.5\include\raylib.h(1111): error C2061: syntax error: identifier 'font'
..\..\libdepwin\raylib2.5\include\raylib.h(1111): error C2059: syntax error: ';'
..\..\libdepwin\raylib2.5\include\raylib.h(1111): error C2059: syntax error: ','
..\..\libdepwin\raylib2.5\include\raylib.h(1111): error C2059: syntax error: ')'
..\..\libdepwin\raylib2.5\include\raylib.h(1112): error C2146: syntax error: missing ')' before identifier 'srcRec'
..\..\libdepwin\raylib2.5\include\raylib.h(1112): error C2081: 'Rectangle': name in formal parameter list illegal
..\..\libdepwin\raylib2.5\include\raylib.h(1112): error C2061: syntax error: identifier 'srcRec'
..\..\libdepwin\raylib2.5\include\raylib.h(1112): error C2059: syntax error: ';'
..\..\libdepwin\raylib2.5\include\raylib.h(1112): error C2059: syntax error: ','
..\..\libdepwin\raylib2.5\include\raylib.h(1112): error C2059: syntax error: ')'
..\..\libdepwin\raylib2.5\include\raylib.h(1113): error C2146: syntax error: missing ')' before identifier 'rec'
..\..\libdepwin\raylib2.5\include\raylib.h(1113): error C2081: 'Rectangle': name in formal parameter list illegal
..\..\libdepwin\raylib2.5\include\raylib.h(1113): error C2061: syntax error: identifier 'rec'
..\..\libdepwin\raylib2.5\include\raylib.h(1113): error C2059: syntax error: ';'
..\..\libdepwin\raylib2.5\include\raylib.h(1113): error C2059: syntax error: ','
..\..\libdepwin\raylib2.5\include\raylib.h(1113): error C2059: syntax error: ')'
..\..\libdepwin\raylib2.5\include\raylib.h(1114): error C2146: syntax error: missing ')' before identifier 'rec'
..\..\libdepwin\raylib2.5\include\raylib.h(1114): error C2081: 'Rectangle': name in formal parameter list illegal
..\..\libdepwin\raylib2.5\include\raylib.h(1114): error C2061: syntax error: identifier 'rec'
..\..\libdepwin\raylib2.5\include\raylib.h(1114): error C2059: syntax error: ';'
..\..\libdepwin\raylib2.5\include\raylib.h(1114): error C2059: syntax error: ','
..\..\libdepwin\raylib2.5\include\raylib.h(1114): error C2059: syntax error: ')'
..\..\libdepwin\raylib2.5\include\raylib.h(1116): error C2146: syntax error: missing ')' before identifier 'font'
..\..\libdepwin\raylib2.5\include\raylib.h(1116): error C2081: 'Font': name in formal parameter list illegal
..\..\libdepwin\raylib2.5\include\raylib.h(1116): error C2061: syntax error: identifier 'font'
..\..\libdepwin\raylib2.5\include\raylib.h(1116): error C2059: syntax error: ';'
..\..\libdepwin\raylib2.5\include\raylib.h(1116): error C2059: syntax error: ','
..\..\libdepwin\raylib2.5\include\raylib.h(1116): error C2059: syntax error: ')'
..\..\libdepwin\raylib2.5\include\raylib.h(1147): error C2146: syntax error: missing ')' before identifier 'sourceRec'
..\..\libdepwin\raylib2.5\include\raylib.h(1147): fatal error C1003: error count exceeds 100; stopping compilation
Microsoft (R) Incremental Linker Version 14.11.25547.0
Copyright (C) Microsoft Corporation.  All rights reserved.

LINK : fatal error LNK1181: cannot open input file 'ring_raylib.obj'
Could Not Find B:\ring\extensions\ringraylib\ring_raylib.obj

Solution

Update raylib.h file

(1) Change typedef struct Rectangle to typedef struct RayRectangle (And update all related functions to use the new name)
(2) Change function CloseWindow to RayCloseWindow
(3) Change function ShowCursor to RayShowCursor
(4) Change function LoadImageA to RayLoadImageA
(5) Change function DrawTextEx to RayDrawTextEx
(6) Change function DrawText to RayDrawText

Changing function names in the header files only is a Workaround, This update must be done at the library source code (*.c file) itself.

Idea : In next versions of RayLib, start all of the function names with something like ray_ to avoid conflict in function names.

Greetings,
Mahmoud

@MahmoudFayed MahmoudFayed changed the title Issue And Solution : RayLib 2.5 Doesn't compile on windows Issue And Solution : RayLib 2.5 Doesn't compile on windows (Visual Studio 2017) Jun 23, 2019
@MahmoudFayed MahmoudFayed changed the title Issue And Solution : RayLib 2.5 Doesn't compile on windows (Visual Studio 2017) Issue And Solution : RayLib 2.5 programs doesn't compile on windows (Visual Studio 2017) Jun 23, 2019
@MahmoudFayed
Copy link
Author

MahmoudFayed commented Jun 23, 2019

Note : This issue happens when the source code uses windows.h

#include <windows.h>

I solved the problem by excluding the code that need windows.h from RingRayLib extension
Now I can use RayLib without any modifications to raylib.h

Thanks!

@a3f
Copy link
Contributor

a3f commented Jun 23, 2019

This issue has been raised multiple times before, last time in #857, which describes a workaround for using both WinAPI and raylib in the same translation unit.

Idea : In next versions of RayLib, start all of the function names with something like ray_ to avoid conflict in function names.

From that issue:

@raysan5: No plans to modify raylib functions for the moment.

As it seems you are fine with using separate translation units, I'll mark the issue closed. Feel free to open new ones whenever issues pop up!

@a3f a3f closed this as completed Jun 23, 2019
@a3f a3f changed the title Issue And Solution : RayLib 2.5 programs doesn't compile on windows (Visual Studio 2017) [build] Issue And Solution : RayLib 2.5 programs doesn't compile on windows (Visual Studio 2017) Jun 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@a3f @MahmoudFayed and others