Reputation: 21
So I downloaded raylib-4.2.0_win64_mingw-w64.zip and used some C VS Code template and changed somethings on the tasks.json
tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"label": "DEBUG-build",
"command": "g++",
"args": [
"-g",
"-std=c++17",
"-m64",
"-O0",
"-Wall",
"${workspaceFolder}/src/*.cpp",
"-o",
"${workspaceFolder}/build/game.exe",
"-I./src",
"-I./src/include",
"-IC:/raylib-mingw64/include",
"-static-libgcc",
"-LC:/raylib-mingw64/lib",
"-lraylib",
"-lopengl32",
"-lgdi32",
"-lwinmm",
"-static-libgcc"
],
"options": {
"cwd": "${workspaceFolder}"
},
"type": "shell",
"group": "build",
"problemMatcher": [],
"dependsOrder": "sequence",
"dependsOn": [
"debug-dir-check",
"DEBUG-quick-clean"
]
},
{
"label": "RELEASE-build",
"command": "g++",
"args": [
"-std=c++17",
"-m64",
"-Ofast",
"${workspaceFolder}/src/*.cpp",
"${workspaceFolder}/src/my.o",
"-o",
"${workspaceFolder}/build/game.exe",
"-I./src",
"-I./src/include",
"-IC:/raylib-mingw64/include",
"-LC:/raylib-mingw64/lib",
"-lraylib",
"-lopengl32",
"-lgdi32",
"-lwinmm",
"-static-libgcc"
],
"options": {
"cwd": "${workspaceFolder}"
},
"type": "shell",
"group": "build",
"problemMatcher": [],
"dependsOrder": "sequence",
"dependsOn": [
"release-dir-check",
"RELEASE-quick-clean",
"MY-RC-build"
]
},
{
"label": "DEBUG-quick-clean",
"command": "del ${workspaceFolder}/build/*.exe ; del ${workspaceFolder}/src/*.o",
"type": "shell",
"group": "build"
},
{
"label": "DEBUG-clean-dist-copy",
"command": "robocopy ${workspaceFolder}/dist ${workspaceFolder}/build *.* /MIR /XF .gitignore ; exit 0",
"type": "shell",
"group": "build"
},
{
"label": "RELEASE-quick-clean",
"command": "del ${workspaceFolder}/build/*.exe ; del ${workspaceFolder}/src/*.o",
"type": "shell",
"group": "build"
},
{
"label": "RELEASE-clean-dist-copy",
"command": "robocopy ${workspaceFolder}/dist ${workspaceFolder}/build *.* /MIR /XF .gitignore ; exit 0",
"type": "shell",
"group": "build"
},
{
"label": "MY-RC-build",
"command": "windres ${workspaceFolder}/src/my.rc ${workspaceFolder}/src/my.o",
"type": "shell",
"group": "build"
},
{
"label": "debug-dir-check",
"command": "cmd",
"args": ["/C", "if not exist ${workspaceFolder}\\build mkdir ${workspaceFolder}\\build"],
"group": "build"
},
{
"label": "release-dir-check",
"command": "cmd",
"args": ["/C", "if not exist ${workspaceFolder}\\build mkdir ${workspaceFolder}\\build"],
"group": "build"
},
]
}
I tried removing "-static-libgcc" and changing the "-std=" version and other stuff.
I basically expeted it to run and create a window not error this:
C:/raylib-mingw64/lib/libraylib.a(rglfw.o):rglfw.c:(.text+0x2b1e): undefined reference to `__imp__wassert'
C:/raylib-mingw64/lib/libraylib.a(rglfw.o):rglfw.c:(.text+0x2ca7): undefined reference to `__imp__wassert'
C:/raylib-mingw64/lib/libraylib.a(rglfw.o):rglfw.c:(.text+0x2ceb): undefined reference to `__imp__wassert'
C:/raylib-mingw64/lib/libraylib.a(rglfw.o):rglfw.c:(.text+0x2d73): undefined reference to `__imp__wassert'
C:/raylib-mingw64/lib/libraylib.a(rglfw.o):rglfw.c:(.text+0x2dad): undefined reference to `__imp__wassert'
C:/raylib-mingw64/lib/libraylib.a(rglfw.o):rglfw.c:(.text+0x364f): more undefined references to `__imp__wassert' follow
collect2.exe: error: ld returned 1 exit status
+Node: It doesn't happen when I don't use raylib functions.
Upvotes: 1
Views: 902
Reputation: 21
I had similar errors yesterday and finally figured out I had to rebuild libraylib.a to match my configuration/platform. (I may have tweaked the file by accident before, through some Makefile or script, and probably ended up with an incompatible version.)
Very simple procedure: go to the Raylib src
folder (mine is located at C:\raylib\raylib\src
), open a cmd terminal (PROTIP: in the path/UID upper bar, write cmd
and then press Enter), and run the following command in the terminal.
make PLATFORM=PLATFORM_DESKTOP -B
Note 1: I shamelessly took the command line from the creator raysan5 here, in a slightly different context (he was referring to building the examples).
Note 2: Apparently, if you only run make
, the compiler will not replace the current version and merely display this without doing anything.
"raylib static library generated (libraylib.a) in ../src!"
On the other hand, running make -B
seems to be enough, but I guess specifying the platform/system instead of having it automatically detected cannot harm you.
Out of curiosity, I took a look at the GCC manual about the -B
option; I am unsure of why this forces compilation. Surely more learned people can tell us.
Upvotes: 2