Build .c file in Window from Linux command.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Dear everyone,
How can I convert the command: !make -f ert_main.c in Linux to the corresponding command in Windows?
Thank you so much!
0 comentarios
Respuestas (1)
Rupesh
el 23 de Feb. de 2024
Editada: Rupesh
el 29 de Feb. de 2024
Hi Hoai An Trinh,
I understand that you are trying to compile a C program using a Makefile on a Windows system, where you would typically use the “make” command on Linux. The “!make -f ert_main.c” command you've mentioned might seem to have a typo; the -f flag is used to specify a Makefile, not a .c source file.
Consider a sample C file named check.c that you intend to compile. You will need to create a Makefile that provides instructions for the make utility on how to build your program. Below is one sample example for Makefile:
# Makefile
all:check
check: check.c
gcc -o check check.c
On Windows, you have a few options depending on the development tools you have installed:
1] Using MinGW or Cygwin
If you have MinGW or Cygwin installed, which provide a Unix-like environment on Windows, you can use the same make command in the MinGW or Cygwin terminal:
Make
2] Using nmake (Microsoft's make)
If you have Microsoft Visual Studio or the Windows SDK, you can use “nmake”. To compile using “nmake”, open a Visual Studio Developer Command Prompt or a command prompt where “cl” and “nmake” are in the PATH, navigate to the directory containing check.c and the Makefile, and run:
nmake
After the execution of the above commands from any of the ways you will get the following output.
In summary, to compile your C program on Windows, you will need to choose the appropriate tool based on what you have installed on your system. If you have a Makefile named ert_main.c, make sure to rename it to just Makefile or use the correct file name after the -f option when invoking “make” or “nmake”.
You can also refer to below documents on how one can build a C or C++ file in windows environment and on MATLAB setup.
Hope this helps!
0 comentarios
Ver también
Categorías
Más información sobre MATLAB Support for MinGW-w64 C/C++ Compiler en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!