Home > Software design >  How do I use premake5 along with MinGW?
How do I use premake5 along with MinGW?

Time:12-27

I have a simple main.c file which just prints hello world and then I've got the 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"

then I ran premake5 gmake2 and it ran perfectly, but when I tried to run make (or mingw32-make) it gave me this error.

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

to make this more interesting, there are no .d files in the bin folder :(

I was expecting a simple hello world program using premake5 and followed the exact steps as provided in the documentations...

CodePudding user response:

The makefile uses cc which is generally an alias on a C-compiler (gcc or clang).

Not familiar with (default) install of MinGW, but if you don't have tha alias, you might still specify the compiler to the generated makefile:

make CC=gcc

CodePudding user response:

Either make sure the location of gcc.exe is in a location that is listed in the PATH environment variable and run:

make CC=gcc

or even:

make CC=gcc.exe

or specify the full path to gcc.exe like this:

make CC="C:\mingw64\bin\gcc.exe"

When using MSYS2 shell and using backslashes make sure to use single quotes:

make CC='C:\mingw64\bin\gcc.exe'

or use slashes instead of backslashes.

  • Related