【问题标题】:How do I use premake5 along with MinGW?我如何将 premake5 与 MinGW 一起使用?
【发布时间】:2023-02-04 19:49:56
【问题描述】:

我有一个简单的 main.c 文件,它只打印 hello world,然后我得到了 premake5.lua。

workspace "HelloWorld"
   configurations { "Debug", "Release" }

project "HelloWorld"
   kind "ConsoleApp"
   language "C"
   targetdir "bin/%{cfg.buildcfg}"

    files {"main.c"}

   filter "configurations:Debug"
      defines { "DEBUG" }
      symbols "On"

   filter "configurations:Release"
      defines { "NDEBUG" }
      optimize "On"

然后我运行 premake5 gmake2 并且运行完美,但是当我尝试运行 make(或 mingw32-make)时它给了我这个错误。

process_begin: CreateProcess(NULL, cc -MD -MP -DDEBUG -g -o obj/Debug/main.o -MF obj/Debug/main.d -c main.c, ...) failed.
make (e=2): The system cannot find the file specified.
make[1]: *** [HelloWorld.make:129: obj/Debug/main.o] Error 2

为了使这更有趣,bin 文件夹中没有 .d 文件:(

我期待一个使用 premake5 的简单 hello world 程序,并按照文档中提供的确切步骤进行操作......

【问题讨论】:

  • 我记得 mingw32-make 有问题。来自 MSYS2 的普通 make 效果更好。
  • 试试make CC=gcc

标签: c++ c gcc mingw premake


【解决方案1】:

确保 gcc.exe 的位置位于 PATH 环境变量中列出的位置并运行:

make CC=gcc

甚至:

make CC=gcc.exe

或者像这样指定gcc.exe的完整路径:

make CC="C:mingw64ingcc.exe"

使用 MSYS2 shell 并使用反斜杠时,请确保使用单引号:

make CC='C:mingw64ingcc.exe'

或者使用斜线代替反斜线。

【讨论】:

    【解决方案2】:

    makefile 使用cc,这通常是 C 编译器(gcc 或 clang)的别名。

    不熟悉 MinGW 的(默认)安装,但如果您没有该别名,您仍然可以为生成的 makefile 指定编译器:

    make CC=gcc
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-23
      • 2012-02-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-10
      相关资源
      最近更新 更多