Thread: Makefiles in windows

  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    17

    Makefiles in windows

    In school we're learning the basics of programming in c. Now we're using makefiles to combine all the .c and .h files into a program. The problem is, all the computers at school are running unix and all you have to do is rightclick the makefile and select make and the computer does the rest for you.

    I don't know anything about using unix and I have windows 7 on my home PC. I'm going crazy trying to find how I can run makefiles in windows to get the same effect. There is no integrated program that does the same and the documentation for the ports of "GNU make" is so complex that I can't find anything in it.

    What i want to do is use the same makefiles from the unix systems at school to compile my program (in c) om my windows pc at home.

    Can anyone help me out?

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    You can find a Win32 version of GNU make here:

    Make for Windows

    Typically, make is used from the command-line. You just execute the 'make' command from the folder containing the makefile. Let us know if you have any installation issues - you may need to edit your PATH variables to include the 'bin' folder or something like that.

  3. #3
    Registered User
    Join Date
    Feb 2010
    Posts
    17
    Thanks sean, I actually managed to get that far and I installed it but from there I don't know how to use it. What is the basic command to use in cmd?

    The makefile i have contains the following code:

    all : product
    CFLAGS = -g

    product.o : product.c product.h
    cc -c $(CFLAGS) product.c

    product : product.o
    cc -o product product.o

    print :
    listing veelt.h veelt.c

    I'm pretty sure that there is some stuff in there that isn't necessary but it shouldn't do any harm. Do I need to place the make executable in the folder that contains the makefile?
    I don't have much experience with command line programs...

  4. #4
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    What is the basic command to use in cmd?
    'make'. Some make files have other 'targets' you can use. In your make file, all, product.o, product, and print are all targets. So 'make all' executes the 'all' target (though I think that one'll get run by default...) and that's probably what you want. Most open source projects have 'deps', 'build', 'install', etc...

    Do I need to place the make executable in the folder that contains the makefile?
    But the directory the installer put it in should be in your PATH variable.

    How to set the windows path in Windows 7

  5. #5
    Registered User
    Join Date
    Feb 2010
    Posts
    17
    But what EXACTLY do I have to type in the cmd. Do i first browse to the path of make? I tried doing that and then typing make.exe and then the path to the makefile but that doesn't work.
    As I said, I'm not used to command line based programs.

  6. #6
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    No - follow the the link I gave you above, and make sure that you add the directory containing make.exe to the PATH variable. Then in cmd, go to the folder containing your makefile, and type 'make'. If that doesn't work, try 'make all'.

  7. #7
    Registered User
    Join Date
    Jan 2010
    Posts
    412
    You also need to have the path to gcc in your PATH variable.

  8. #8
    Registered User
    Join Date
    Feb 2010
    Posts
    17
    Thank you!
    I've manged to get it working. That trick with PATH is very useful to know.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Windows 98/2000 programming in Windows XP
    By Bill83 in forum Windows Programming
    Replies: 3
    Last Post: 07-22-2005, 02:16 PM
  2. Dialog Box Problems
    By Morgul in forum Windows Programming
    Replies: 21
    Last Post: 05-31-2005, 05:48 PM
  3. dual boot Win XP, win 2000
    By Micko in forum Tech Board
    Replies: 6
    Last Post: 05-30-2005, 02:55 PM
  4. SDL and Windows
    By nickname_changed in forum Windows Programming
    Replies: 14
    Last Post: 10-24-2003, 12:19 AM
  5. IE 6 status bar
    By DavidP in forum Tech Board
    Replies: 15
    Last Post: 10-23-2002, 05:31 PM