Archivo de compilacion .mak para Visual Studio
Archivo de compilacion .mak para Visual Studio
Saludos,
Alguien utiliza archivos .mak para compilar con Visual Studio?
Necesito hacerle una consulta
Gracias de antemano
Alguien utiliza archivos .mak para compilar con Visual Studio?
Necesito hacerle una consulta
Gracias de antemano
Last edited by Compuin on Sun Jan 19, 2025 7:36 pm, edited 2 times in total.
FWH 20.12
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
- Antonio Linares
- Site Admin
- Posts: 42393
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 9 times
- Been thanked: 41 times
- Contact:
Re: Archivo de compilacion .mak para Visual Studio
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
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
FWH 20.12
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
- Antonio Linares
- Site Admin
- Posts: 42393
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 9 times
- Been thanked: 41 times
- Contact:
Re: Archivo de compilacion .mak para Visual Studio
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
Gracias maestro, lo probaré
FWH 20.12
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
Re: Archivo de compilacion .mak para Visual Studio
me da este error
Y este es el .mak
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>
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$@
FWH 20.12
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
- Antonio Linares
- Site Admin
- Posts: 42393
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 9 times
- Been thanked: 41 times
- Contact:
Re: Archivo de compilacion .mak para Visual Studio
Prueba a cambiar esto:
link /out:$@ $^
por:
link /out:$@ $*
ó
link /out:$@ $**
link /out:$@ $^
por:
link /out:$@ $*
ó
link /out:$@ $**
Re: Archivo de compilacion .mak para Visual Studio
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$@
FWH 20.12
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
- Antonio Linares
- Site Admin
- Posts: 42393
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 9 times
- Been thanked: 41 times
- Contact:
Re: Archivo de compilacion .mak para Visual Studio
Que código hay en la línea 70 ?
> tutor04.mak(70) : fatal error U1001: syntax error : illegal character '<' in macro
> tutor04.mak(70) : fatal error U1001: syntax error : illegal character '<' in macro
Re: Archivo de compilacion .mak para Visual Studio
$(CC) $(CFLAGS) /c $< /Fo$@
FWH 20.12
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
Re: Archivo de compilacion .mak para Visual Studio
Nuevo error
Aca el .mak ajustado
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
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
FWH 20.12
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
- Antonio Linares
- Site Admin
- Posts: 42393
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 9 times
- Been thanked: 41 times
- Contact:
Re: Archivo de compilacion .mak para Visual Studio
Modifica esta línea así:
$(VCDIR)\link @msvc.tmp /nologo /subsystem:windows /NODEFAULTLIB:libucrt /NODEFAULTLIB:msvcrt /force:multiple > link.log
y enlaza ucrt.lib
$(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
Master,
Me sigue dando el mismo error.
Aqui esta el contenido del log
Como le digo al Link que los obj estan en la carpeta \OBJ y no en la \PRG ??
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>
Code: Select all | Expand
LINK : fatal error LNK1181: cannot open input file 'prg\one.OBJ'
FWH 20.12
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
- Antonio Linares
- Site Admin
- Posts: 42393
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 9 times
- Been thanked: 41 times
- Contact:
Re: Archivo de compilacion .mak para Visual Studio (RESUELTO)
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)
Ahora arroja nuevo error y creo que viene de esta linea
Code: Select all | Expand
OBJS=$(OBJ:prg\=obj\)
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.
Last edited by Compuin on Sun Jan 19, 2025 7:52 pm, edited 1 time in total.
FWH 20.12
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code