How to run a makefile in Windows?

730,987

Solution 1

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:

nmake -f Makefile.win

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.

Solution 2

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.

  1. Install the chocolatey package manager for Windows
    compatible to Windows 7+ / Windows Server 2003+

  2. 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.

Solution 3

Check out cygwin, a Unix alike environment for Windows

Solution 4

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:

winget install GnuWin32.Make

Also, be sure to add the install path to your system PATH:

C:\Program Files (x86)\GnuWin32\bin

Solution 5

Here is my quick and temporary way to run a Makefile

  • download make from SourceForge: gnuwin32
  • install it
  • go to the install folder

C:\Program Files (x86)\GnuWin32\bin

  • copy the all files in the bin to the folder that contains Makefile

libiconv2.dll libintl3.dll make.exe

  • open the cmd (you can do it with right click with shift) in the folder that contains Makefile and run

make.exe

done.

Plus, you can add arguments after the command, such as

make.exe skel

Share:
730,987

Related videos on Youtube

Kim
Author by

Kim

Updated on June 11, 2021

Comments

  • Kim
    Kim over 1 year

    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?

    • Kim
      Kim over 12 years
      I should mention that I'm more of a Linux person but I need to use Windows right now, so I'm a little clueless.
    • Scott
      Scott almost 3 years
      Very clear guide is given here
  • Kim
    Kim over 12 years
    How do I run the visual studio command prompt from the start menu?
  • Kim
    Kim over 12 years
    Alright I figured it out. But of course it wouldn't compile because of errors. Just my luck. Thanks though.
  • undeniablyrob over 9 years
    For those with VS2012, the command prompt is called "Developer Command Prompt for VS2012". Start--> Search--> "command" is how I found it.
  • Alex S
    Alex S over 9 years
    @NSD: You can try other "make"s, but such files are usually written against nmake's dialect and with the assumption that VS is installed and on the path. You might find that the free VS Express suffices.
  • Cheeku
    Cheeku over 9 years
    @MarceloCantos I am a noob to Linux and Making. What if I have .am and .mk file. I don't have any .win file. I am trying to make wget, btw.
  • Alex S
    Alex S over 9 years
    @Cheeku: That's a different question and has little to do with programming. Why don't you just install it from whatever package manager your Linux distro has?
  • Cheeku
    Cheeku over 9 years
    @MarceloCantos How to do it on Windows? Not using cygwin or GNU Make, instead using VS Developer Command Prompt
  • The Mask
    The Mask over 8 years
    Great! how do I make nmake callabre from Windows console? just edit path variable so that it find the executable?
  • Alex S
    Alex S over 8 years
    @TheMask: That's explained in the answer.
  • searchengine27
    searchengine27 over 7 years
    What about for those of us that don't have it in the start menu? navigating to the MSVS cmd prompt via the start menu is not a valid answer. I don't know the exact command it executes, but all that thing in the start menu is a shortcut to some executable with a few command line switches - none of which I remember - all of which I want to know what they are. The start menu can't help everyone
  • searchengine27
    searchengine27 over 7 years
    I obtained a copy of MSVS 2010 C++, and this is what the command line was for that shortcut '%comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"" x86'. This isn't quite what I remember, but either way, there it is. It looks like in this case all its doing is setting up the environment for a regular shell
  • Alex S
    Alex S over 7 years
    @searchengine27: Afaict, it was a valid answer five years ago.
  • searchengine27
    searchengine27 over 7 years
    @MarceloCantos No, it was never a valid answer. Unless you're saying that the "MSVS Command Prompt" was its own individual executable, and that MSVS mandated that you always have that in the start menu (both of which I know for a fact are not true), then that was never a valid answer. Other people happening to have it in the start menu because they/their company installed it in such a fashion does not correlate to this being a valid answer. It is a helpful answer to some people, but you're confusing that with valid to the question. I suggest updating your answer to make it valid.
  • Alex S
    Alex S over 7 years
    @searchengine27: It's a valid answer for anyone installing the product in the standard way. It has always been there for me, even in corporate environments. If some enterprise IT shop wants to do weird shit, that's their business.
  • Damien Leroux
    Damien Leroux over 6 years
    cygwin worked well for me!. I just had to check, during installation, some packages in Devel : 'make' and also 'gcc' as explained here.
  • zygimantus
    zygimantus over 4 years
    I also recommend to install cygwin using chocolatey, so the command to get make is this: choco install make --source=cygwin
  • Yukulélé
    Yukulélé over 4 years
    It's probably better to add bin directory to PATH environment variable. This will make make.exe available from anywhere.
  • JFFIGK over 4 years
    I think its done by default - at least that was the case when I installed gnuwin32. Of course copying the files is bad practice anyway.
  • XaBerr
    XaBerr over 4 years
    after I installed with choco, how can I add it to my command shell? there is a path to be added?
  • ccy
    ccy about 4 years
    In addition, please add "C:\Program Files (x86)\GnuWin32\bin" to your system PATH.
  • Ali.Ghodrat about 4 years
    In case you installed it with choco, then add this line (witought quotation marks) to your path variable in the system variables "C:\tools\cygwin\bin"
  • jciloa almost 4 years
    If your makefile contains Linux commands as well, you cannot use this approach, you need Cygwin.
  • Victor
    Victor almost 4 years
    It is not done by default (or not in my case). By adding it to the path, then you can run make from the project folder.
  • trungducng over 2 years
    Work like a champ
  • KyleMit
    KyleMit about 2 years
    You also might want to consider changing the install directory to avoid spaces and parenthesis as they can cause issues running the CLI
  • Tumo Masire over 1 year
    You are amazing, thanks so much. Runs as if trying the Makefile on a native Linux environment, but in windows! Was having issues with make using WSL, for a gui Java app, but this made it work using PowerShell.
  • Joshua Santiago about 1 year
    Worked great, thank you

Related