Как запустить makefile под WINDOWS.
Не так давно я пересел на AtmelStudio6 с AVRStudio4. Есть у меня классный программатор клон STK500. Который просто прекрасно работает с 4й версией. Вот и получается, что пишу я теперь проги под 6й версией, а программатором пользуюсь из под 4ой. Неудобно как то. Попробовал подключить программатор к 6й. Работает через пень колоду. То работает, то не работает. Решил я сделать новый, чтоб работал по 6й версией и не пукал. Решил что это будет AVRISP mkII.
Нарыл я проект LUFA. ТУТ
Скачал код, а там торчит makefile. Самой прошивки там нет, чтоб сразу залить в микроконтроллер. Значит надо запустить сборку makefile чтоб родился hex файл. А как это сделать? Без понятия. А надо. Начал рыть. Помог один товарищ линуксоид. Вместе с ним поколупались и нарыли вот что.
1). Установить прогу mingw-get-inst-20120426.exe. В одном из окон при установке галочку поставить напротив msys. Эта прога есть здесь.
2). Установить прогу bc-1.06-2.exe. Отсюда.
3). Указать путь для переменной PATH в XP 32bit,
Переменная PATH находится здесь.
Компьютер/свойства/дополнительно/переменные среды.
C:\MinGW\msys\1.0\bin;
C:\Program Files\GnuWin32\bin;
C:\Program Files\Atmel\Atmel Toolchain\AVR8 GCC\Native\3.4.2.939\avr8-gnu-toolchain\bin
Для WINDIWS_7 64bit
C:\MinGW\msys\1.0\bin;
C:\Program Files (x86)\GnuWin32\bin;
C:\Program Files (x86)\Atmel\Atmel Toolchain\AVR8 GCC\Native\3.4.2.939\avr8-gnu-toolchain\bin
4).Открыть консоль, зайти в нужную папку где находится файл make. Набрать команду make. Вот и все. Там же и появится желанный hex файл. Команда Make clean очищает от прежней сборки файлов.
Вот можно видео глянуть как это происходит.
Продолжение здесь.
Как запустить make-файл в Windows?
У меня есть некоторые загруженные демонстрации, которые идут с Makefile.win и Makefile.sgi. Как я могу запустить их в Windows, чтобы скомпилировать демки?
Если у вас есть Visual Studio, запустите командную строку Visual Studio из меню «Пуск», перейдите в каталог, содержащий Makefile.win и введите следующее:
Вы также можете использовать обычную командную строку и запустить vsvars32.bat (c: \ Program Files (x86) \ Microsoft Visual Studio 9.0 \ Common7 \ Tools for VS2008). Это настроит среду для запуска nmake и поиска инструментов компилятора.
Ознакомьтесь с Cygwin , Unix-подобной средой для Windows
Проверьте GnuWin «s делает , что обеспечивает родной порт для ОС Windows (без необходимости полной среды выполнения , как Cygwin)
Вот мой быстрый и временный способ запустить Makefile
- скачать сделайте из SourceForge: gnuwin32
- установить его
- перейти в папку установки
C: \ Program Files (x86) \ GnuWin32 \ bin
- скопируйте все файлы в папке с папкой, содержащей Makefile
- откройте cmd(вы можете сделать это с помощью правого клика со смещением ) в папке, содержащей Makefile, и запустите
Кроме того, вы можете добавить аргументы после команды, такие как
Этот вопрос может быть старым, но мое решение, которое является самым простым для любого пользователя Windows, я полагаю, не указано в списке.
Шаг 1: Установите менеджер пакетов шоколада для WINDOWS (совместимый с Windows 7+ / Windows Server 2003+) здесь
Шаг 2: беги choco install make
Шаг 3: Прибыль от ухоженного менеджера пакетов. Make будет добавлен в глобальный путь и работает на всех CLI (powershell, git bash, cmd…)
Я не связан с choco, но это просто хорошо.
Если вы устанавливаете Cygwin . Убедитесь, что в программе установки выбрано make. Затем вы можете запустить следующую команду, если у вас есть Makefile.
В Visual Studio 2017 мне пришлось добавить эту папку в переменную env пути Windows 10:
Там также HostX86
Во-первых, добавьте путь общих инструментов visual studio ( c:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools ) в системный путь. Чтобы узнать, как добавить путь в системный путь, посетите этот веб-сайт: http://www.computerhope.com/issues/ch000549.htm . Тебе просто нужно это один раз.
После этого, когда вам нужно, откройте командную строку и выполните команду, vsvars32.bat чтобы добавить пути всех необходимых инструментов Visual Studio в системный путь.
Затем вы можете позвонить nmake -f makefile.mak
PS: Путь к обычным инструментам Visual Studio может отличаться в вашей системе. Пожалуйста, измените его соответственно.
Если это «Makeake-файл NMake», то есть синтаксис и команда совместимы с NMake, он будет работать в Windows. Обычно Makefile.win ( .win суффикс) указывает, что это make-файл, совместимый с Windows NMake. Так что вы можете попробовать nmake -f Makefile.win .
Часто предоставляются стандартные файлы Makefile для Linux, которые NMake выглядят многообещающе. Тем не менее, следующая ссылка берет простой Linux Makefile и объясняет некоторые фундаментальные проблемы, с которыми можно столкнуться. Он также предлагает несколько альтернатив для обработки Linux Makefiles в Windows.
Я попробовал с cygwin & gnuwin, и у меня ничего не вышло, наверное, потому что в make-файле использовался в основном специфический код Linux.
Он работал с Ubuntu Bash для Windows 10 . Это чудо, если вы пришли из MAC, так как это мой случай:
- Чтобы установить Ubuntu Bash: https://itsfoss.com/install-bash-on-windows/
- Оказавшись в консоли, для установки make просто наберите «make», и он даст инструкции для его загрузки.
Дополнительно:
- Полезное включение копирования / вставки в Bash: Копировать Вставить в Bash в Ubuntu в Windows
- В моем случае эта модель называется Maven, поэтому я должен установить ее также: /ubuntu/722993/unable-to-locate-package-maven
- Для доступа к файловой системе C: Windows, например: «cd / mnt / c /»
Я использую набор инструментов MinGW , который предоставляет mingw32-make инструмент для сборки, если он есть в вашей PATH системной переменной , в командной строке Windows просто перейдите в каталог, содержащий файлы, и введите следующую команду:
How to install and use “make” in Windows?
I’m following the instructions of someone whose repository I cloned to my machine. What I want is simple: to be able to use the make command as part of setting up the code environment. But I’m using Windows, and I searched online only to find a make.exe file to download, a make-4.1.tar.gz file to download (I don’t know what to do with it next), and things about downloading MinGW (for GNU; but after installing it I didn’t find any mention of «make»).
I don’t want a GNU compiler or related stuff; I only want to use «make» in Windows. Please tell me what I should do to accomplish that.
Thanks in advance!
10 Answers 10
make is a GNU command so the only way you can get it on Windows is installing a Windows version like the one provided by GNUWin32. Anyway, there are several options for getting that:
The most simple choice is using Chocolatey. First you need to install this package manager. Once installed you simlpy need to install make (you may need to run it in an elevated/admin command prompt) :
Other recommended option is installing a Windows Subsystem for Linux (WSL/WSL2), so you’ll have a Linux distribution of your choice embedded in Windows 10 where you’ll be able to install make , gcc and all the tools you need to build C programs.
For older Windows versions (MS Windows 2000 / XP / 2003 / Vista / 2008 / 7 with msvcrt.dll) you can use GnuWin32.
An outdated alternative was MinGw, but the project seems to be abandoned so it’s better to go for one of the previous choices.
How to run a makefile in Windows?
I have some demos that I downloaded and they come with a Makefile.win and a Makefile.sgi. How can I run these in Windows to compile the demos?
17 Answers 17
If you have Visual Studio, run the Visual Studio Command prompt from the Start menu, change to the directory containing Makefile.win and type this:
You can also use the normal command prompt and run vsvars32.bat (c:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\Tools for VS2008). This will set up the environment to run nmake and find the compiler tools.
You can install GNU make with chocolatey, a well-maintained package manager, which will add make to the global path and runs on all CLIs (powershell, git bash, cmd, etc…) saving you a ton of time in both maintenance and initial setup to get make running.
Install the chocolatey package manager for Windows
compatible to Windows 7+ / Windows Server 2003+
Run choco install make
I am not affiliated with choco, but I highly recommend it, so far it has never let me down and I do have a talent for breaking software unintentionally.
Check out cygwin, a Unix alike environment for Windows
Check out GnuWin’s make (for windows), which provides a native port for Windows (without requiring a full runtime environment like Cygwin)
If you have winget, you can install via the CLI like this:
Also, be sure to add the install path to your system PATH :
Here is my quick and temporary way to run a Makefile
- download make from SourceForge: gnuwin32
- install it
- go to the install folder
- copy the all files in the bin to the folder that contains Makefile
- open the cmd(you can do it with right click with shift) in the folder that contains Makefile and run
Plus, you can add arguments after the command, such as
If you install Cygwin. Make sure to select make in the installer. You can then run the following command provided you have a Makefile.
With Visual Studio 2017 I had to add this folder to my Windows 10 path env variable:
There’s also HostX86
If it is a «NMake Makefile», that is to say the syntax and command is compatible with NMake, it will work natively on Windows. Usually Makefile.win (the .win suffix) indicates it’s a makefile compatible with Windows NMake. So you could try nmake -f Makefile.win .
Often standard Linux Makefiles are provided and NMake looks promising. However, the following link takes a simple Linux Makefile and explains some fundamental issues that one may encounter. It also suggests a few alternatives to handling Linux Makefiles on Windows.
I use MinGW tool set which provides mingw32-make build tool, if you have it in your PATH system variables, in Windows Command Prompt just go into the directory containing the files and type this command:
Firstly, add path of visual studio common tools ( c:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools ) into the system path. To learn how to add a path into system path, please check this website: http://www.computerhope.com/issues/ch000549.htm. You just need to this once.
After that, whenever you need, open a command line and execute vsvars32.bat to add all required visual studio tools’ paths into the system path.
Then, you can call nmake -f makefile.mak
PS: Path of visual studio common tools might be different in your system. Please change it accordingly.
I tried with cygwin & gnuwin, and didn’t worked for me, I guess because the makefile used mainly specific linux code.
What it worked was use Ubuntu Bash for Windows 10. This is a Marvel if you come from MAC as it is my case:
- To install the Ubuntu Bash: https://itsfoss.com/install-bash-on-windows/
- Once in the console, to install make simply type «make» and it gives the instructions to download it.
Extras:
- Useful enable copy / paste on bash: Copy Paste in Bash on Ubuntu on Windows
- In my case the make called Maven, so I have to install it as well: https://askubuntu.com/questions/722993/unable-to-locate-package-maven
- To access windows filesystem C: drive, for example: «cd /mnt/c/»
I tried all of the above. What helps me:
- Download the mingw-get.
- Setup it.
- Add something like this C:\MinGW\bin to environment variables.
- Launch (!important) git bash. Power shell, developer vs cmd, system cmd etc didn’t help.
- Type mingw-get into the command line.
- After type mingw-get install mingw32-make .
Done! Now You might be able to use make-commands from any folder that contains Makefile.
- Download from https://sourceforge.net/projects/gnuwin32/
- Set the variable path in advance setting for recognize in command prompt (C:\Program Files (x86)\GnuWin32\bin)
Install msys2 with make dependency add both to PATH variable. (The second option is GNU ToolChain for Windows. MinGW version has already mingw32-make included.)
Install Git Bash. Run mingw32-make from Git Bash.
I am assuming you added mingw32/bin is added to environment variables else please add it and I am assuming it as gcc compiler and you have mingw installer.
First step: download mingw32-make.exe from mingw installer, or please check mingw/bin folder first whether mingw32-make.exe exists or not, else than install it, rename it to make.exe .
After renaming it to make.exe , just go and run this command in the directory where makefile is located. Instead of renaming it you can directly run it as mingw32-make .
After all, a command is just exe file or a software, we use its name to execute the software, we call it as command.
How to create an empty file at the command line in Windows?
How to create an empty file at the DOS/Windows command-line?
but it always displays that a file was copied.
Is there any other method in the standard cmd?
It should be a method that does not require the touch command from Cygwin or any other nonstandard commands. The command needs to run from a script so keystrokes cannot be used.
33 Answers 33
In the same spirit, Samuel suggests in the comments:
the shortest one I use is basically the one by Nomad:
It does give an error:
But this error is on stderr. And > only redirects stdout, where nothing have been produced.
Hence the creation of an empty file.
The error message can be disregarded here. Or, as in Rain’s answer, redirected to NUL :
(Original answer, November 2009)
( echo «» would actually put «» in the file! And echo without the ‘.’ would put » Command ECHO activated » in the file. )
Note: the resulting file is not empty but includes a return line sequence: 2 bytes.
This discussion points to a true batch solution for a real empty file:
The » » pipes a nul response to the set/p command, which will cause the variable used to remain unchanged. As usual with set/p , the string to the right of the equal sign is displayed as a prompt with no CRLF.
Since here the «string to the right of the equal sign» is empty. the result is an empty file.
The difference with cd. > filename (which is mentioned in Patrick Cuff’s answer and does also produce a 0-byte-length file) is that this «bit of redirection» (the trick) can be used to echo lines without any CR:
The dir command should indicate the file size as 11 bytes: » helloworld! «.