所以我下载了raylib-4.2.0_win64_mingw-w64.zip并使用了一些C VS Code模板并更改了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"
},
]
}
我尝试删除“-static-libgcc”并更改“-std=”版本和其他内容。
我基本上希望它运行并创建一个窗口而不是错误:
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:当我不使用 raylib 函数时,不会发生这种情况。
我昨天遇到了类似的错误,最后发现我必须重建 libraylib.a 以匹配我的配置/平台。 (我之前可能通过一些 Makefile 或脚本意外地调整了该文件,并且可能最终得到了不兼容的版本。)
非常简单的过程:进入Raylib
src
文件夹(我的位于C:\raylib\raylib\src
),打开cmd终端(PROTIP:在路径/UID上方栏中,写下cmd
,然后按Enter键),然后运行在终端中输入以下命令。
make PLATFORM=PLATFORM_DESKTOP -B
注1:我无耻地从创建者raysan5here那里获取了命令行,在一个稍微不同的上下文中(他指的是构建示例)。
注2:显然,如果你only运行
make
,编译器不会替换当前版本,只是显示它而不做任何事情。
“在../src中生成了raylib静态库(libraylib.a)!”
另一方面,运行
make -B
似乎就足够了,但我想指定平台/系统而不是自动检测它不会对你造成伤害。
出于好奇,我查看了GCC手册关于-B
选项的内容;我不确定为什么这会强制编译。当然更多有学识的人可以告诉我们。