Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22045

Why is Premake5 producing incorrect file separator on Windows?

$
0
0

I am trying to use premake5 to build a simple C project using Visual Studio Code on Windows and I'm getting the below error:

$ make config=release_win64"==== Building calc (release_win64) ===="Creating obj/win64/Release"main.c"process_begin: CreateProcess(NULL, cc -MD -MP -DNDEBUG -Isrc/include -m64 -Werror -flto -O3 -o obj/win64/Release/main.o -MF obj/win64/Release/main.d -c src/main.c, ...) failed.make (e=2): The system cannot find the file specified.make[1]: *** [calc.make:153: obj/win64/Release/main.o] Error 2make: *** [Makefile:36: calc] Error 2

I strongly suspect that it is not able to handle the file separator for windows correctly. Please help me understand what am I doing incorrectly with my premake5.lua script.

Here are the details:

Project Folder Structure

- Project Root    - src        - include            - sum.h        - main.c        - sum.c    - premake5.lua

premake5.lua

workspace "calc"    configurations { "Debug", "Release" }    platforms { "win64", "linux64" }project "calc"    kind "ConsoleApp"    language "C"    targetname "calc"    targetdir "bin/%{cfg.buildcfg}"    entrypoint ("main()")    includedirs { "src/include" }    files { "src/**.h", "src/**.c" }    filter { "platforms:linux64" }        system "linux"        architecture "x86_64"    filter { "platforms:win64" }        system "windows"        architecture "x86_64"        toolset "gcc"    filter { "configurations:Debug" }        flags { "FatalWarnings" }        defines { "DEBUG" }        symbols "On"    filter { "configurations:Release" }        flags { "FatalWarnings", "LinkTimeOptimization" }        defines { "NDEBUG" }        optimize "speed"

main.c

#include "include/sum.h"#include <stdio.h>int main() {    int a = 1;    int b = 2;    int result = sum(a, b);    printf("%d + %d = %d", a, b, result);    return 0;}

Sum.h

#ifndef SUM_H#define SUM_Hint sum(int a, int b);#endif

sum.c

#include "include/sum.h"int sum(int a, int b) {    return a + b;}

Build commands

$ premake5 gmake2Building configurations...Running action 'gmake2'...Done (57ms).$ make config=release_win64"==== Building calc (release_win64) ====""main.c"process_begin: CreateProcess(NULL, cc -MD -MP -DNDEBUG -Isrc/include -m64 -Werror -flto -O3 -o obj/win64/Release/main.o -MF obj/win64/Release/main.d -c src/main.c, ...) failed.make (e=2): The system cannot find the file specified.make[1]: *** [calc.make:153: obj/win64/Release/main.o] Error 2make: *** [Makefile:36: calc] Error 2

Auto generated Makefile

# Alternative GNU Make workspace makefile autogenerated by Premakeifndef config  config=debug_win64endififndef verbose  SILENT = @endififeq ($(config),debug_win64)  calc_config = debug_win64else ifeq ($(config),debug_linux64)  calc_config = debug_linux64else ifeq ($(config),release_win64)  calc_config = release_win64else ifeq ($(config),release_linux64)  calc_config = release_linux64else  $(error "invalid configuration $(config)")endifPROJECTS := calc.PHONY: all clean help $(PROJECTS) all: $(PROJECTS)calc:ifneq (,$(calc_config))    @echo "==== Building calc ($(calc_config)) ===="    @${MAKE} --no-print-directory -C . -f calc.make config=$(calc_config)endifclean:    @${MAKE} --no-print-directory -C . -f calc.make cleanhelp:    @echo "Usage: make [config=name] [target]"    @echo ""    @echo "CONFIGURATIONS:"    @echo "  debug_win64"    @echo "  debug_linux64"    @echo "  release_win64"    @echo "  release_linux64"    @echo ""    @echo "TARGETS:"    @echo "   all (default)"    @echo "   clean"    @echo "   calc"    @echo ""    @echo "For more information, see https://github.com/premake/premake-core/wiki"

Auto generated calc.make file

# Alternative GNU Make project makefile autogenerated by Premakeifndef config  config=debug_win64endififndef verbose  SILENT = @endif.PHONY: clean prebuildSHELLTYPE := posixifeq (.exe,$(findstring .exe,$(ComSpec)))    SHELLTYPE := msdosendif# Configurations# #############################################RESCOMP = windresINCLUDES += -Isrc/includeFORCE_INCLUDE +=ALL_CPPFLAGS += $(CPPFLAGS) -MD -MP $(DEFINES) $(INCLUDES)ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)LIBS +=LDDEPS +=LINKCMD = $(CC) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)define PREBUILDCMDSendefdefine PRELINKCMDSendefdefine POSTBUILDCMDSendefifeq ($(config),debug_win64)TARGETDIR = bin/DebugTARGET = $(TARGETDIR)/calc.exeOBJDIR = obj/win64/DebugDEFINES += -DDEBUGALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -Werror -gALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m64 -Werror -gALL_LDFLAGS += $(LDFLAGS) -L/usr/lib64 -m64else ifeq ($(config),debug_linux64)TARGETDIR = bin/DebugTARGET = $(TARGETDIR)/calcOBJDIR = obj/linux64/DebugDEFINES += -DDEBUGALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -Werror -gALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m64 -Werror -gALL_LDFLAGS += $(LDFLAGS) -L/usr/lib64 -m64else ifeq ($(config),release_win64)TARGETDIR = bin/ReleaseTARGET = $(TARGETDIR)/calc.exeOBJDIR = obj/win64/ReleaseDEFINES += -DNDEBUGALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -Werror -flto -O3ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m64 -Werror -flto -O3ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib64 -m64 -flto -selse ifeq ($(config),release_linux64)TARGETDIR = bin/ReleaseTARGET = $(TARGETDIR)/calcOBJDIR = obj/linux64/ReleaseDEFINES += -DNDEBUGALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -Werror -flto -O3ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m64 -Werror -flto -O3ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib64 -m64 -flto -sendif# Per File Configurations# ############################################## File sets# #############################################GENERATED :=OBJECTS :=GENERATED += $(OBJDIR)/main.oGENERATED += $(OBJDIR)/sum.oOBJECTS += $(OBJDIR)/main.oOBJECTS += $(OBJDIR)/sum.o# Rules# #############################################all: $(TARGET)    @:$(TARGET): $(GENERATED) $(OBJECTS) $(LDDEPS) | $(TARGETDIR)    $(PRELINKCMDS)    @echo Linking calc    $(SILENT) $(LINKCMD)    $(POSTBUILDCMDS)$(TARGETDIR):    @echo Creating $(TARGETDIR)ifeq (posix,$(SHELLTYPE))    $(SILENT) mkdir -p $(TARGETDIR)else    $(SILENT) mkdir $(subst /,\\,$(TARGETDIR))endif$(OBJDIR):    @echo Creating $(OBJDIR)ifeq (posix,$(SHELLTYPE))    $(SILENT) mkdir -p $(OBJDIR)else    $(SILENT) mkdir $(subst /,\\,$(OBJDIR))endifclean:    @echo Cleaning calcifeq (posix,$(SHELLTYPE))    $(SILENT) rm -f  $(TARGET)    $(SILENT) rm -rf $(GENERATED)    $(SILENT) rm -rf $(OBJDIR)else    $(SILENT) if exist $(subst /,\\,$(TARGET)) del $(subst /,\\,$(TARGET))    $(SILENT) if exist $(subst /,\\,$(GENERATED)) del /s /q $(subst /,\\,$(GENERATED))    $(SILENT) if exist $(subst /,\\,$(OBJDIR)) rmdir /s /q $(subst /,\\,$(OBJDIR))endifprebuild: | $(OBJDIR)    $(PREBUILDCMDS)ifneq (,$(PCH))$(OBJECTS): $(GCH) | $(PCH_PLACEHOLDER)$(GCH): $(PCH) | prebuild    @echo $(notdir $<)    $(SILENT) $(CC) -x c-header $(ALL_CFLAGS) -o "$@" -MF "$(@:%.gch=%.d)" -c "$<"$(PCH_PLACEHOLDER): $(GCH) | $(OBJDIR)ifeq (posix,$(SHELLTYPE))    $(SILENT) touch "$@"else    $(SILENT) echo $null >> "$@"endifelse$(OBJECTS): | prebuildendif# File Rules# #############################################$(OBJDIR)/main.o: src/main.c    @echo "$(notdir $<)"    $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"$(OBJDIR)/sum.o: src/sum.c    @echo "$(notdir $<)"    $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"-include $(OBJECTS:%.o=%.d)ifneq (,$(PCH))  -include $(PCH_PLACEHOLDER).dendif

Make version

$ make --versionGNU Make 4.4.1Built for Windows32Copyright (C) 1988-2023 Free Software Foundation, Inc.License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>This is free software: you are free to change and redistribute it.There is NO WARRANTY, to the extent permitted by law.

GCC Version

$ gcc --versiongcc.exe (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 8.1.0Copyright (C) 2018 Free Software Foundation, Inc.This is free software; see the source for copying conditions.  There is NOwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Operating System

Edition Windows 11Version 23H2OS build    22631.4169Experience  Windows Feature Experience Pack 1000.22700.1034.0

Device Specifications

Processor   Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz   2.59 GHzInstalled RAM   8.00 GB (7.80 GB usable)System type 64-bit operating system, x64-based processor

PATH

$ echo %PATH%<OTHERS>;C:\mingw64\bin;C:\Program Files\premake-5.0.0-beta2-windows

Viewing all articles
Browse latest Browse all 22045

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>