Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: GNU gcc make problem

08 Dec 2013   #1
chrstdvd

Microsoft Windows 7 Professional 64-bit 7601 Multiprocessor Free Service Pack 1
 
 
GNU gcc make problem

I am learning to program in C. I have Code Blocks installed and working great and have used it to write code to learn.

I want to write code in Notepad ++ and compile it in Power Shell which is set up. I have GNU gcc in C:\Gnu gcc and Code Blocks finds an uses it, [I added it to the environment path] as well as, Power Shell; if i type in gcc ex1.c -o ex1.exe, the .exe there works with ./ex1 or if i type in invoke-item ex1.exe, then the command window comes up with the output listed. I use the getchar() to make it stay on screen so I can see the result.

I am working through the tutorial Learn C the Hard Way Learn C The Hard Way
The author wants us to use MAKE. I can not make MAKE work.

I have Googled and Googled and Googled for how to make it work. My Make exe is in GNU gcc\mysys\1.0.

I read that I should cope make.exe into GNU gcc\bin which I did and at least I get error messages like "file not found". If it is not there, I get Make is not a commandlet ... error in Power Shell.

I can not find MAKEFILE anywhere.

I have bookmarked several how to's to make my own MAKEFILE but to heck with that if I have to create or change it for each .c file i want to compile.

Is there a generic MAKEFILE that will compile all simple lesson .c files?

Thanks
David


My System SpecsSystem Spec
.
08 Dec 2013   #2
oneeyed

Windows 8
 
 

Easy way would be to add C:\Gnu gcc\bin\ (or wherever you want to put make) to your environment path.

Methinks you can specify from which directory/location make operates... Here is a page which might interest you : Environment Variables - Using the GNU Compiler Collection (GCC)
My System SpecsSystem Spec
09 Dec 2013   #3
chrstdvd

Microsoft Windows 7 Professional 64-bit 7601 Multiprocessor Free Service Pack 1
 
 

Thanks, I added the path to the "make.exe" file to the environmental path.

Now when I try to run make I get this:
PS C:\Users\David\Cprojects> make ex1
cc ex1.c -o ex1
make.exe": cc: Command not found
make.exe": *** [ex1] Error 127

I tried several example Makefile's in the working directory but all I get from them are NO Rules.

I am wondering about the tab rule for constructing a Makefile file

I put a tab at the beginning of every line and in every white space.

Is that the correct way to do it?
My System SpecsSystem Spec
.

10 Dec 2013   #4
chrstdvd

Microsoft Windows 7 Professional 64-bit 7601 Multiprocessor Free Service Pack 1
 
 

OK, last night I found a basic Makefile and it would not work either but the error messages clued me into line numbers were failing, so I commented them out and re-typed them using the Tab rule for every white space. The final error was that it could not find CC, so I added a line," "CC = gcc" Tab'ed properly and tried again.

Success! It works for all my little projects while I learn to program in C and I do not have to modify anything in it as I go. I am sure it is only for one file at a time other than the header files in the .c itself.

Here it is, if anyone else ever has the problem. But if you use it make sure to use the tab for white spaces rather than the space bar.

HEADERS = program.h headers.h
OBJECTS = program.o
CC = gcc
CFLAGS = -g -Wall
default: program

%.o: %.c $(HEADERS)
#gcc -c $< -o $@
gcc -c $< -o $a@

program: $(OBJECTS)
#gcc $(OBJECTS) -o $@
gcc $(OBJECTS) -O $@

clean:
#-rm -f $(OBJECTS)
-rm -F $(OBJECTS)

#-rm -f program
-rm -f program
My System SpecsSystem Spec
Reply

 GNU gcc make problem




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
Problem to make windows Multiboot USB
I want to make a Multiboot USB with Windows XP, Seven, 8 and Windows 7 Live. Problem is Seven and 8 are same with directory and file name. So File and directory will be overwritten if i do it manually. I tried Yumi and other tools to do this job. These tools give the chance to add only seven or 8....
General Discussion
Is there is a way to make windows to not save the problem reports
Every time I program crash or somethings goes wrong,windows creates a error report which is supposed to be sended to Microsoft for a solution. Most of the time(if not all of the time),when I program crash,I was expecting it to crash or I know the reason or I'm trying something multiple times that...
General Discussion
How to make Windows make a sound when done pasting
I often copy and paste very large files, 50 gigs and so on and it takes a very long time. Is there a way for windows to make a sound when the copying is done? Thanks
General Discussion
Will it make difference to make partition at beginning or end of HDD?
Hi. I have two hdds (500gb 7200rpm) in my laptop and have 260gb of data on the second one. I wanted to create a partition for games at the beggining of the 2nd drive (the left side) as i heard it increased performance to put games in anoher drive and at the beggining of the drive. My question...
Performance & Maintenance
Problem repair ,reinstall, make FreeAgent bootable , find HD serial
Hello All, I have many inquiries now here is my situation : I am not sure weather my machine is infected. It happens after I installed clock creensaver; after reboot to window 7, there is an information identified around that the previous hardware or software installation may cause...
Installation & Setup
Make ISO from DVD/Change to univeral install make USB
Ok I've only been a member for a short time and like this site. Lots of info. What I want to do is make a Win 7 ISO file from my DVD install disk. Which is a retail upgrade version. Then I want to change the install routine to make that ISO a universal install ISO. Then I want to make a USB...
Installation & Setup


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 08:45.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App