Compiling a Small Gcc Project on Windows Using MinGW

therefore, I have been programming in C ++ for almost 2 years, and all this time, when I enjoyed using IDE (VS) with excellent project settings and automatic binding, etc. I always stayed outside of any external libraries that required me to compile via make files, or at least those intended for Linux / other compilers.

In any case, now I want to use a super-useful utility ( Bob Jenkins Perfect Minimal Hash) , but this requires me to compile through make files, not just that, but using the g ++ compiler.

I went ahead and got the mingW32-make utility, and now I'm trying to get it to work. Where am I now:

  • Successfully installed minGW
  • Successfully called make utility
  • Failed to complete the project.

The error I am getting is:

C: \ gen_progs \ ph> mingw32 - do

mingw32-make: *** There is no rule to do target lookupa.c', needed by lookupa.o'. Stop.

And makefile itself:

 CFLAGS = -O .cc.o: gcc $(CFLAGS) -c $< O = lookupa.o recycle.o perfhex.o perfect.o const64 : $(O) gcc -o perfect $(O) -lm # DEPENDENCIES lookupa.o : lookupa.c standard.h lookupa.h recycle.o : recycle.c standard.h recycle.h perfhex.o : perfhex.c standard.h lookupa.h recycle.h perfect.h perfect.o : perfect.c standard.h lookupa.h recycle.h perfect.h 

Now the error seems reasonable, at least from my minimal understanding of make files, I have all the files with the .c, .h binding, however I don't have a single .o file, and there seem to be no instructions on how to do this . So my questions are:

Am I calling make utility incorrectly? Or do I need to compile object files first? Or ... do I need to add something to the make file?

Again I have all the .c and .h links.

Edit: Sorry that I was actually missing from this particular file, which seems to have disappeared somewhere along the line. However, adding it back is the error I am now getting:

 c:\gen_progs\ph>mingw32-make cc -O -c -o lookupa.o lookupa.c process_begin: CreateProcess(NULL, cc -O -c -o lookupa.o lookupa.c, ...) failed. make (e=2): The system cannot find the file specified. mingw32-make: *** [lookupa.o] Error 2 
+4
source share
3 answers

Regarding your error, "process_begin: CreateProcess (NULL, cc -O -c -o lookupa.o lookupa.c, ...) failed."

This is because the make utility wants to use the "cc" compiler to compile your program, but this compiler is not part of the Mingw package.

Decision. Change ".cc.o:" to ".co:". This modifies the implicit rule that tells which compiler to use (gcc on the next line) when compiling .c files (the source line tells how to compile .cc files).

+9
source

Saying either make -DCC=gcc on the command line, or adding the line CC=gcc to the top of the Makefile will also fix the problem. In the rules for processing the C source code, create the entire name of the C compiler with the CC variable, which defaults to "cc" for backward compatibility reasons even in Gnu Make.

It seems that the original author of Makefile tried to work around this problem by providing a custom rule for compiling .cc files, but since there are no .cc files in the project, this rule was not actually used.

Specifying the correct value for CC superior to correcting the explicit rule for the .c IMHO file name because Makefiles are usually easier to use and maintain and are most portable when the smallest possible information is specified.

+7
source

I do not think the problem is with the .o files. Make will make them from the source files (files to the right of the colon).

Your immediate problem is that make cannot file lookupa.c file. From the rules you posted, it seems to me that this file should be in the same directory as the makefile, but it is not. You need to find out where this file is and how to get it.

(For some reason, I have a mental image of Wile E. Coyote sitting on his computer, seeing this file name, looking up and plastered with an anvil).

+1
source

All Articles