You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Premake 5编译GLFW失败求助:系统找不到指定文件

解决Premake编译GLFW时的cc找不到问题

错误核心原因:Windows环境下无默认cc编译器命令,Premake生成的Makefile默认调用cc,但你的环境未配置该命令指向可用的C编译器。

解决步骤

  1. 确认已安装C编译器(如MinGW-w64 GCC或MSVC),并将其添加到系统PATH中。
  2. 在premake5.lua中明确指定编译器,覆盖Premake的默认设置:

修改后的premake5.lua

workspace "glfw"
    configurations { "debug", "release" }
    -- 若使用MinGW GCC,添加此行
    toolset "gcc"
    -- 若使用MSVC,替换为 toolset "msc"

project "glfw"
    kind "ConsoleApp"
    language "C"

    targetdir("bin/glfw/")
    objdir("obj/glfw/")

    files
    {
        "include/GLFW/glfw3.h",
        "include/GLFW/glfw3native.h",
        "src/context.c",
        "src/init.c",
        "src/input.c",
        "src/monitor.c",

        "src/null_init.c",
        "src/null_joystick.c",
        "src/null_monitor.c",
        "src/null_window.c",

        "src/platform.c",
        "src/vulkan.c",
        "src/window.c",

        "src/win32_init.c",
        "src/win32_joystick.c",
        "src/win32_module.c",
        "src/win32_monitor.c",
        "src/win32_time.c",
        "src/win32_thread.c",
        "src/win32_window.c",
        "src/wgl_context.c",
        "src/egl_context.c",
        "src/osmesa_context.c"
    }

    defines
    {
        "_GLFW_WIN32",
        "_CRT_SECURE_NO_WARNINGS"
    }

    filter "configurations:debug"
        runtime "Debug"
        symbols "on"

额外验证

  • 打开命令行,输入gcc --version(MinGW)或cl(MSVC),确认编译器能正常响应,说明PATH配置正确。
  • 使用MSVC时,需在VS开发者命令提示符下执行make命令,确保MSVC环境变量已加载。

内容的提问来源于stack exchange,提问作者elijah

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.30 23:17:05