I'm trying to remake Pong from scratch using C. I've built the game and now I want to actually see it. I'm using Windows 10 with VSCode (most likely the issue).
My tasks.json command:
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-std=c99",
"-I\"D:\\forrk\\C Game\\raylib-5.0_win64_mingw-w64\\include\"",
"-L\"D:\\forrk\\C Game\\raylib-5.0_win64_mingw-w64\\lib\"",
"-lraylib",
"-o2",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
Compiler:
gcc --version
gcc.exe (Rev2, Built by MSYS2 project) 13.2.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
This is the error message I'm getting every time (yes I have it in Spanish, "compilar archivo activo" means "compile active file", "Iniciando la compilación" means "Beginning compilation", "La compilación ha finalizado con errores" means "Compilation finished with errors"):
Executing task: C/C++: gcc.exe compilar archivo activo
Iniciando la compilación...
D:\forrk\_tool\ucrt64\bin\gcc.exe -fdiagnostics-color=always -g "D:\forrk\C Game\pong.c" -std=c99 -I"D:\forrk\C Game\raylib-5.0_win64_mingw-w64\include" -L"D:\forrk\C Game\raylib-5.0_win64_mingw-w64\lib" -lraylib -o2 -o "D:\forrk\C Game\pong.exe"
D:/forrk/_tool/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:\forrk\C Game\raylib-5.0_win64_mingw-w64\lib/libraylib.a(rcore.o):rcore.c:(.text+0x1c494): undefined reference to `timeEndPeriod'
La compilación ha finalizado con errores.
* The terminal process failed to launch (exit code: -1).
* Terminal will be reused by tasks, press any key to close it.
I installed raylib in the following manners: 1- Putting everything in the project folder: IntelliSense finds it but tasks.json didn't. 2- Fixed tasks.json and moved the 'include' and 'lib' folders outside their original folder: No errors or warning when using #include, but still won't compile. 3- Moving 'lib' to its own folder in C: (as suggested by other posts): no effect
Is this a VSCode issue? Am I doing something wrong? I got my version off raylib.com -> github, also tried cloning with git directly just to get the same results.
Ideally I want to use VSCode for C and not need to touch anything on Visual Studio (which I have set up for C# and Unity)
The timeEndPeriod
function is defined in the winmm
library so you need to add -lwinmm
to the set of linker options, after -lraylib
.
Also note that it should be -O2
(meaning optimization level 2), not -o2
(meaning that the output file should be named 2
):
"-lraylib",
"-lwinmm",
"-O2",