0

I'm getting an error in the compilation of a C file that heavily uses Raylib function.

Environment

  • OS: Windows 10
  • IDE: Visual Studio Code
  • Raylib version: 4.2.0 (win64, mingw)

Sanity check of Raylib installation

Following the discussions in How to add Raylib to VS code?, I successfully compiled an example code: main.c in this link. That means, the Raylib function is correctly installed, and the path to the source libraries is also set correctly.

Compilation of my code

Using the set of JSON files (c_cpp_properties.json, launch.json, settings.json, tasks.json) used in the example code, I'm trying to compile my code. There are several ways to compile code on VS code.

  • Compilation by F5 key

    In this case, I get the following messages on my terminal:

    Executing task: C:\MinGW\bin\mingw32-make.exe RAYLIB_PATH=C:/raylib/raylib PROJECT_NAME=MyCode OBJS=MyCode.c BUILD_MODE=DEBUG 
    
    mingw32-make: *** No targets specified and no makefile found.  Stop.
    

    It seems like I need to make a Makefile to configure the compilation but I have no idea how to write it. I tried using the Makefile in link but it caused an error. I probably need to make a code-specific Makefile but I have no clue.

  • Compilation by command #1

    I also tried to compile my code by running the following command on VS code terminal:

    gcc MyCode.c lib/librarylib.a -o MyCode
    

    but I got the following error message:

    fatal error: raylib.h: No such file or directory
    

    The header file raylib.h is not recognized even though I used the same header in the example code I compiled earlier. The path to the header is also set properly.

  • Compilation by command #2

    To set the path to the file location of raylib.h more explicitly, I used the following command instead:

    gcc -Wall -IC:\raylib\raylib\src MyCode.c MyCode.exe -l/librarylib -o a.out
    

    Note that the C:\raylib\raylib\src is the path to a folder that contains raylib.h. This time I got the following error:

    gcc.exe: error: MyCode.c: No such file or directory
    gcc.exe: error: MyCode.exe: No such file or directory  
    

Some clues ...

I got this code from another guy. The code was originally developed on M1 mac, and it was compiled successfully by the following command:

clang -framework CoreVideo -framework IOKit -framework Cocoa -framework GLUT -framework OpenGL lib/libraylib.a MyCode.c -o MyCode
Ogiad
  • 139
  • 1
  • 11

0 Answers0