Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8382815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:00:49+00:00 2026-06-09T17:00:49+00:00

I am currently failing to write a good makefile and don’t know the reason

  • 0

I am currently failing to write a good makefile and don’t know the reason why.. -.-

This is my main.c:

#include <windows.h>
#include <stdio.h>

int main(int argc, char *argv[])
{ 
   printf("MEEEEEP");
   return (0);
}

This is my makefile:

# make SYSTEM= OS= ENVIRONMENT=
# Binaries to use
ifeq ($(ENVIRONMENT),MINGW)
  CXX   = i686-pc-mingw32-g++
else
  CXX   = g++
endif
REMOVE  = rm -vf

RC      = windres
EXE     = .exe

#############################################################
# Info

ifeq ($(CXX),g++)
INFO_CXX = g++ -dumpversion; g++ -dumpmachine
endif

#############################################################
# Flags

DEBUG = -DDEBUG -g
OPTIMIZATION = -O2 #-Winline -finline-functions

CFLAGS = -Wall -Wextra -W -static $(DEBUG) $(OPTIMIZATION) -D$(SYSTEM) -D$(OS) -D$(ENVIRONMENT) $(PRGFLAGS)

ifeq ($(SYSTEM),I686)
  CFLAGS   += -m32

  ifeq ($(OS),WIN32)
    CFLAGS += -D_WIN32 
  endif

  ifeq ($(ENVIRONMENT),MINGW)
    CFLAGS += -fexceptions 
  endif
endif

 LFLAGS    = 

#############################################################
# Files

CFILES      = main.c
OBJS        = ${CFILES:.c=.o}

#############################################################
# Include

INCLUDES      = -I.

#############################################################
# Library

LIBRARIES     = 

#############################################################
# Targets
.PHONY: all
all:    
    @echo == Standard build: make SYSTEM=I686 OS=WIN32 ENVIRONMENT=MINGW
    @echo
    @echo 
    make SYSTEM=I686 OS=WIN32 ENVIRONMENT=MINGW gyro

#############################################################
# Implicit rules and filename extensions... 
.SUFFIXES: .h .o .c

.c.o:     %.h
      @echo Compiling $< for $(SYSTEM) $(OS) $(ENVIRONMENT) ...
      @echo MEEP
      $(CXX) $(CFLAGS) $(INCLUDES) -c $< -o $@
      @echo MEEP2

#############################################################
# Target rules
gyro: $(OBJS)
      @echo Building software for $(SYSTEM) ...
      @echo
      $(CXX) $(CFLAGS) $(LFLAGS) -o $@$(EXE) $(OBJS) $(LIBRARIES)

#############################################################
# Clean
.PHONY: clean
clean:
    $(REMOVE) $(OBJS)


#############################################################
# Info
.PHONY: info
info:
    @echo 
    @echo Information about C++ Compiler/Linker:
    @echo 
    $(INFO_CXX)

When i type in make gyro,
i receive the output:

Compiling main.c for Windows_NT ...
MEEP
g++ -Wall -Wextra -W -static -DDEBUG -g -O2  -D -DWindows_NT -D  -I. -c main.c -o     main.o
makeNew.mak:83: recipe for target `main.o' failed
make: *** [main.o] Error 1

But Line number 83 is behind .c.o: %.h. And i don’t understand why.
Does anyone have a solution for me?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T17:00:50+00:00Added an answer on June 9, 2026 at 5:00 pm

    You see the two empty -D entries in the g++ command line? They’re causing the problem. You must have values in the -D items e.g. -DWIN32

    if you’re insistent on using something like -D$(SYSTEM) -D$(ENVIRONMENT) then you can use something like:

    SYSTEM ?= generic
    ENVIRONMENT ?= generic
    

    in the makefile which gives them default values.

    Your output looks to be missing the all important output:

    <command-line>:0:1: error: macro names must be identifiers
    <command-line>:0:1: error: macro names must be identifiers
    

    just to clarify, what actually got sent to g++ was -D -DWindows_NT, i.e. define a preprocessor macro called -DWindows_NT; which is of course not a valid identifier (similarly for -D -I.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Why is glReadPixels() failing in this code in iOS 6.0? I currently
Currently I have this code: <?php echo '<meta name=robots content=noindex>'; $arr = json_decode(file_get_contents(http://media1.clubpenguin.com/play/en/web_service/game_configs/ paper_items.json),true);
I currently have a win 32 application which emits popup windows based on different
I am currently failing to achieve a successful transformation of an SVG image into
Why this database query failing? in my CentOS. Error/Exception: Notice: Undefined variable: table in
I'm currently trying to learn proper unit-test. So now I'm trying to write unit-tests
I've got a Windows application running some expensive equipment; this application dies in a
I'm currently migrating my LAMP from my Windows Server to a VPS running Debian
Currently, I am writing a MiddleWare application that synchronizes information between and accounting application
Currently I am using HTML files for parts of my user interface. I display

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.