Page 1 of 3
Archivo de compilacion .mak para Visual Studio
Posted: Fri Jan 17, 2025 9:08 pm
by Compuin
Saludos,
Alguien utiliza archivos .mak para compilar con Visual Studio?
Necesito hacerle una consulta
Gracias de antemano
Re: Archivo de compilacion .mak para Visual Studio
Posted: Fri Jan 17, 2025 11:20 pm
by Antonio Linares
Que necesitas ?
Re: Archivo de compilacion .mak para Visual Studio
Posted: Fri Jan 17, 2025 11:26 pm
by Compuin
Hola maestro,
Necesito crearlo indicándole que los .prg y los .c están alojados en carpetas tales como PRG y C y no en el mismo directorio del ejecutable
Re: Archivo de compilacion .mak para Visual Studio
Posted: Fri Jan 17, 2025 11:45 pm
by Antonio Linares
A ver si te sirve esto:
Code: Select all | Expand
# Variables de rutas
PRG_PATH = src\prg
C_PATH = src\c
OBJ_PATH = obj
# Variables para los compiladores y banderas
CC = cl
CFLAGS = /I $(PRG_PATH) /I $(C_PATH) /nologo
# Archivos fuente y objetivos
PRG_FILES = $(PRG_PATH)\file1.prg $(PRG_PATH)\file2.prg
C_FILES = $(C_PATH)\main.c $(C_PATH)\utils.c
OBJ_FILES = $(OBJ_PATH)\main.obj $(OBJ_PATH)\utils.obj
# Regla para construir el programa
all: program.exe
program.exe: $(OBJ_FILES)
link /out:$@ $^
# Regla para compilar archivos .c
$(OBJ_PATH)\%.obj: $(C_PATH)\%.c
$(CC) $(CFLAGS) /c $< /Fo$@
# Limpieza
clean:
del /Q $(OBJ_PATH)\*.obj program.exe
Re: Archivo de compilacion .mak para Visual Studio
Posted: Fri Jan 17, 2025 11:54 pm
by Compuin
Gracias maestro, lo probaré
Re: Archivo de compilacion .mak para Visual Studio
Posted: Sat Jan 18, 2025 1:16 am
by Compuin
me da este error
Code: Select all | Expand
Microsoft (R) Program Maintenance Utility Version 14.30.30706.0
Copyright (C) Microsoft Corporation. All rights reserved.
tutor04.mak(77) : fatal error U1001: syntax error : illegal character '^' in macro
Stop.
C:\vs2022_make>Clinica32.exe
'Clinica32.exe' is not recognized as an internal or external command,
operable program or batch file.
C:\vs2022_make>
Y este es el .mak
Code: Select all | Expand
#Microsoft VS2019 make sample, (c) FiveTech Software 2022
HBDIR=c:\harbour_msvc
FWDIR=c:\fwh
VCDIR=C:\vc2022\bin32
SDKDIR=C:\vc2022\bin32
# Variables de rutas
PRG_PATH = prg
C_PATH = c
OBJ_PATH = obj
# Variables para los compiladores y banderas
CC = cl
CFLAGS = /I $(PRG_PATH) /I $(C_PATH) /nologo
# Archivos fuente y objetivos
PRG_FILES = $(PRG_PATH)\Clinica32.prg $(PRG_PATH)\Clinica32Win.prg $(PRG_PATH)\TPublic.prg
C_FILES = $(C_PATH)\Clinica32.c $(C_PATH)\Clinica32Win.c $(C_PATH)\TPublic.c
OBJ_FILES = $(OBJ_PATH)\Clinica32.obj $(OBJ_PATH)\Clinica32Win.obj $(OBJ_PATH)\TPublic.obj
# Regla para construir el programa
all: program.exe
# link /OUT:Clinica32.exe @msvc.tmp /nologo /subsystem:windows /force:multiple /NODEFAULTLIB:msvcrt
program.exe: $(OBJ_FILES)
echo $(FWDIR)\lib\FiveH32.lib $(FWDIR)\lib\FiveHC32.lib >> msvc.tmp
echo $(HBDIR)\lib\win\msvc\hbrtl.lib >> msvc.tmp
echo $(HBDIR)\lib\win\msvc\hbvm.lib >> msvc.tmp
echo $(HBDIR)\lib\win\msvc\gtgui.lib >> msvc.tmp
echo $(HBDIR)\lib\win\msvc\hblang.lib >> msvc.tmp
echo $(HBDIR)\lib\win\msvc\hbmacro.lib >> msvc.tmp
echo $(HBDIR)\lib\win\msvc\hbrdd.lib >> msvc.tmp
echo $(HBDIR)\lib\win\msvc\rddntx.lib >> msvc.tmp
echo $(HBDIR)\lib\win\msvc\rddcdx.lib >> msvc.tmp
echo $(HBDIR)\lib\win\msvc\rddfpt.lib >> msvc.tmp
echo $(HBDIR)\lib\win\msvc\hbsix.lib >> msvc.tmp
echo $(HBDIR)\lib\win\msvc\hbdebug.lib >> msvc.tmp
echo $(HBDIR)\lib\win\msvc\hbcommon.lib >> msvc.tmp
echo $(HBDIR)\lib\win\msvc\hbpp.lib >> msvc.tmp
echo $(HBDIR)\lib\win\msvc\hbwin.lib >> msvc.tmp
echo $(HBDIR)\lib\win\msvc\hbcplr.lib >> msvc.tmp
echo $(HBDIR)\lib\win\msvc\xhb.lib >> msvc.tmp
echo $(HBDIR)\lib\win\msvc\hbpcre.lib >> msvc.tmp
echo $(HBDIR)\lib\win\msvc\hbct.lib >> msvc.tmp
echo $(HBDIR)\lib\win\msvc\hbcpage.lib >> msvc.tmp
echo $(HBDIR)\lib\win\msvc\hbzlib.lib >> msvc.tmp
echo $(HBDIR)\lib\win\msvc\png.lib >> msvc.tmp
echo $(HBDIR)\lib\win\msvc\hbziparc.lib >> msvc.tmp
echo $(HBDIR)\lib\win\msvc\hbmzip.lib >> msvc.tmp
echo $(HBDIR)\lib\win\msvc\minizip.lib >> msvc.tmp
echo kernel32.lib >> msvc.tmp
echo user32.lib >> msvc.tmp
echo gdi32.lib >> msvc.tmp
echo winspool.lib >> msvc.tmp
echo comctl32.lib >> msvc.tmp
echo comdlg32.lib >> msvc.tmp
echo advapi32.lib >> msvc.tmp
echo shell32.lib >> msvc.tmp
echo ole32.lib >> msvc.tmp
echo oleaut32.lib >> msvc.tmp
echo uuid.lib >> msvc.tmp
echo odbc32.lib >> msvc.tmp
echo odbccp32.lib >> msvc.tmp
echo iphlpapi.lib >> msvc.tmp
echo mpr.lib >> msvc.tmp
echo version.lib >> msvc.tmp
echo wsock32.lib >> msvc.tmp
echo msimg32.lib >> msvc.tmp
echo oledlg.lib >> msvc.tmp
echo psapi.lib >> msvc.tmp
echo gdiplus.lib >> msvc.tmp
echo winmm.lib >> msvc.tmp
echo ws2_32.lib >> msvc.tmp
link /out:$@ $^
# Regla para compilar archivos .c
$(OBJ_PATH)\%.obj: $(C_PATH)\%.c
$(CC) $(CFLAGS) /c $< /Fo$@
Re: Archivo de compilacion .mak para Visual Studio
Posted: Sat Jan 18, 2025 10:00 am
by Antonio Linares
Prueba a cambiar esto:
link /out:$@ $^
por:
link /out:$@ $*
ó
link /out:$@ $**
Re: Archivo de compilacion .mak para Visual Studio
Posted: Sat Jan 18, 2025 1:29 pm
by Compuin
Ahora sale esto
Code: Select all | Expand
Microsoft (R) Program Maintenance Utility Version 14.30.30706.0
Copyright (C) Microsoft Corporation. All rights reserved.
tutor04.mak(70) : fatal error U1001: syntax error : illegal character '<' in macro
Stop.
C:\vs2022_make>Clinica32.exe
'Clinica32.exe' is not recognized as an internal or external command,
operable program or batch file.
C:\vs2022_make>
Code: Select all | Expand
link /out:$@ $*
# Regla para compilar archivos .c
$(OBJ_PATH)\%.obj: $(C_PATH)\%.c
$(CC) $(CFLAGS) /c $< /Fo$@
Re: Archivo de compilacion .mak para Visual Studio
Posted: Sat Jan 18, 2025 5:10 pm
by Antonio Linares
Que código hay en la línea 70 ?
> tutor04.mak(70) : fatal error U1001: syntax error : illegal character '<' in macro
Re: Archivo de compilacion .mak para Visual Studio
Posted: Sat Jan 18, 2025 6:08 pm
by Compuin
$(CC) $(CFLAGS) /c $< /Fo$@
Re: Archivo de compilacion .mak para Visual Studio
Posted: Sat Jan 18, 2025 10:01 pm
by Compuin
Nuevo error
Code: Select all | Expand
LINK : warning LNK4068: /MACHINE not specified; defaulting to X86
LINK : error LNK2001: unresolved external symbol WinMainCRTStartup
one.exe : fatal error LNK1120: 1 unresolved externals
Aca el .mak ajustado
Code: Select all | Expand
# Microsoft VS2022 make sample, (c) FiveTech Software 2022
# Rutas de herramientas y librerías
HBDIR=c:\harbour_msvc
FWDIR=c:\fwh
VCDIR=c:\vc2022\bin32
.SUFFIXES: .prg .c .obj .rc .res
PRG = \
prg\one.PRG \
prg\two.PRG \
prg\three.PRG
OBJ=$(PRG:.PRG=.OBJ)
OBJS=$(OBJ:.\=.\obj\)
PROJECT: one.EXE
# Enlace final
one.exe : $(OBJS) one.res
echo $(OBJS) > msvc.tmp
@echo Vinculando...
@echo $(FWDIR)\lib\FiveH32.lib $(FWDIR)\lib\FiveHC32.lib > msvc.tmp
@echo $(HBDIR)\lib\win\msvc\hbrtl.lib >> msvc.tmp
@echo $(HBDIR)\lib\win\msvc\hbvm.lib >> msvc.tmp
@echo $(HBDIR)\lib\win\msvc\gtgui.lib >> msvc.tmp
@echo $(HBDIR)\lib\win\msvc\hblang.lib >> msvc.tmp
@echo $(HBDIR)\lib\win\msvc\hbmacro.lib >> msvc.tmp
@echo $(HBDIR)\lib\win\msvc\hbrdd.lib >> msvc.tmp
@echo $(HBDIR)\lib\win\msvc\rddntx.lib >> msvc.tmp
@echo $(HBDIR)\lib\win\msvc\rddcdx.lib >> msvc.tmp
@echo $(HBDIR)\lib\win\msvc\rddfpt.lib >> msvc.tmp
@echo $(HBDIR)\lib\win\msvc\hbsix.lib >> msvc.tmp
@echo kernel32.lib >> msvc.tmp
@echo user32.lib >> msvc.tmp
@echo gdi32.lib >> msvc.tmp
@echo winspool.lib >> msvc.tmp
@echo comctl32.lib >> msvc.tmp
@echo comdlg32.lib >> msvc.tmp
@echo advapi32.lib >> msvc.tmp
@echo shell32.lib >> msvc.tmp
@echo ole32.lib >> msvc.tmp
@echo oleaut32.lib >> msvc.tmp
@echo uuid.lib >> msvc.tmp
@echo odbc32.lib >> msvc.tmp
@echo odbccp32.lib >> msvc.tmp
@echo iphlpapi.lib >> msvc.tmp
@echo mpr.lib >> msvc.tmp
@echo version.lib >> msvc.tmp
@echo wsock32.lib >> msvc.tmp
@echo msimg32.lib >> msvc.tmp
@echo oledlg.lib >> msvc.tmp
@echo psapi.lib >> msvc.tmp
@echo gdiplus.lib >> msvc.tmp
@echo winmm.lib >> msvc.tmp
@echo ws2_32.lib >> msvc.tmp
IF EXIST one.res echo one.res >> msvc.tmp
$(VCDIR)\link @msvc.tmp /nologo /subsystem:windows /force:multiple > link.log
@type link.log
one.res : one.rc
$(VCDIR)\rc.exe -r -d__FLAT__ one.rc
.prg.obj:
$(HBDIR)\bin\harbour $< /n /w /Oobj\ /i$(FWDIR)\include;$(HBDIR)\include
$(VCDIR)\cl.exe -TP -W3 -c /GS- /I$(HBDIR)\include /GA -Foobj\ obj\*.c
Re: Archivo de compilacion .mak para Visual Studio
Posted: Sat Jan 18, 2025 10:29 pm
by Antonio Linares
Modifica esta línea así:
$(VCDIR)\link @msvc.tmp /nologo /subsystem:windows /NODEFAULTLIB:libucrt /NODEFAULTLIB:msvcrt /force:multiple > link.log
y enlaza ucrt.lib
Re: Archivo de compilacion .mak para Visual Studio
Posted: Sat Jan 18, 2025 10:40 pm
by Compuin
Master,
Me sigue dando el mismo error.
Code: Select all | Expand
one.c
three.c
two.c
Generating Code...
echo prg\one.OBJ prg\two.OBJ prg\three.OBJ > msvc.tmp
Vinculando...
IF EXIST one.res echo one.res >> msvc.tmp
c:\vc2022\bin32\link @msvc.tmp /nologo /subsystem:windows /NODEFAULTLIB:libucrt /NODEFAULTLIB:msvcrt /force:multiple > link.log
NMAKE : fatal error U1077: 'c:\vc2022\bin32\link' : return code '0x460'
Stop.
C:\vs2022_make>one.exe
'one.exe' is not recognized as an internal or external command,
operable program or batch file.
C:\vs2022_make>
Aqui esta el contenido del log
Code: Select all | Expand
LINK : fatal error LNK1181: cannot open input file 'prg\one.OBJ'
Como le digo al Link que los obj estan en la carpeta \OBJ y no en la \PRG ??
Re: Archivo de compilacion .mak para Visual Studio (RESUELTO)
Posted: Sun Jan 19, 2025 7:20 pm
by Antonio Linares
Prueba así:
Code: Select all | Expand
# Microsoft VS2022 make sample, (c) FiveTech Software 2022
# Rutas de herramientas y librerías
HBDIR=c:\harbour_msvc
FWDIR=c:\fwh
VCDIR=c:\vc2022\bin32
.SUFFIXES: .prg .c .obj .rc .res
PRG = \
prg\one.PRG \
prg\two.PRG \
prg\three.PRG
# Modified to correctly reference obj folder
OBJ=$(PRG:.PRG=.obj)
OBJS=$(OBJ:prg\=obj\)
PROJECT: one.EXE
# Enlace final
one.exe : $(OBJS) one.res
echo $(OBJS) > msvc.tmp
@echo Vinculando...
@echo $(FWDIR)\lib\FiveH32.lib $(FWDIR)\lib\FiveHC32.lib > msvc.tmp
@echo $(HBDIR)\lib\win\msvc\hbrtl.lib >> msvc.tmp
@echo $(HBDIR)\lib\win\msvc\hbvm.lib >> msvc.tmp
@echo $(HBDIR)\lib\win\msvc\gtgui.lib >> msvc.tmp
@echo $(HBDIR)\lib\win\msvc\hblang.lib >> msvc.tmp
@echo $(HBDIR)\lib\win\msvc\hbmacro.lib >> msvc.tmp
@echo $(HBDIR)\lib\win\msvc\hbrdd.lib >> msvc.tmp
@echo $(HBDIR)\lib\win\msvc\rddntx.lib >> msvc.tmp
@echo $(HBDIR)\lib\win\msvc\rddcdx.lib >> msvc.tmp
@echo $(HBDIR)\lib\win\msvc\rddfpt.lib >> msvc.tmp
@echo $(HBDIR)\lib\win\msvc\hbsix.lib >> msvc.tmp
@echo kernel32.lib >> msvc.tmp
@echo user32.lib >> msvc.tmp
@echo gdi32.lib >> msvc.tmp
@echo winspool.lib >> msvc.tmp
@echo comctl32.lib >> msvc.tmp
@echo comdlg32.lib >> msvc.tmp
@echo advapi32.lib >> msvc.tmp
@echo shell32.lib >> msvc.tmp
@echo ole32.lib >> msvc.tmp
@echo oleaut32.lib >> msvc.tmp
@echo uuid.lib >> msvc.tmp
@echo odbc32.lib >> msvc.tmp
@echo odbccp32.lib >> msvc.tmp
@echo iphlpapi.lib >> msvc.tmp
@echo mpr.lib >> msvc.tmp
@echo version.lib >> msvc.tmp
@echo wsock32.lib >> msvc.tmp
@echo msimg32.lib >> msvc.tmp
@echo oledlg.lib >> msvc.tmp
@echo psapi.lib >> msvc.tmp
@echo gdiplus.lib >> msvc.tmp
@echo winmm.lib >> msvc.tmp
@echo ws2_32.lib >> msvc.tmp
IF EXIST one.res echo one.res >> msvc.tmp
$(VCDIR)\link @msvc.tmp /nologo /subsystem:windows /force:multiple > link.log
@type link.log
one.res : one.rc
$(VCDIR)\rc.exe -r -d__FLAT__ one.rc
.prg.obj:
$(HBDIR)\bin\harbour $< /n /w /Oobj\ /i$(FWDIR)\include;$(HBDIR)\include
$(VCDIR)\cl.exe -TP -W3 -c /GS- /I$(HBDIR)\include /GA -Foobj\ obj\*.c
Re: Archivo de compilacion .mak para Visual Studio (RESUELTO)
Posted: Sun Jan 19, 2025 7:32 pm
by Compuin
Ahora arroja nuevo error y creo que viene de esta linea
Code: Select all | Expand
C:\vc2022_MAK>nmake one.mak
Microsoft (R) Program Maintenance Utility Version 14.30.30706.0
Copyright (C) Microsoft Corporation. All rights reserved.
NMAKE : fatal error U1073: don't know how to make 'obj\one.obj'
Stop.
C:\vc2022_MAK>one.exe
'one.exe' is not recognized as an internal or external command,
operable program or batch file.