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 5949107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:12:09+00:00 2026-05-22T17:12:09+00:00

I have the following Makefile CXX = g++ CXXFLAGS = -g -Wall COMPILE =

  • 0

I have the following Makefile

CXX = g++
CXXFLAGS = -g -Wall
COMPILE = ${CXX} ${CXXFLAGS} -c
LINK = ${CXX} -lpthread
LIB_INC = -Ilib -Iwrappers -Iprocesses

src := $(wildcard lib/*.cpp) $(wildcard wrappers/*.cpp)
obj = $(src:.cpp=.o)

src_1 := processnetwork_part001.cpp sc_application_1.cpp
obj_1 = $(src_1:.cpp=.o)
src_2 := processnetwork_part002.cpp sc_application_2.cpp
obj_2 = $(src_2:.cpp=.o)

all : sc_application_1 sc_application_2
.PHONY : all

sc_application_1 : ${obj} ${obj_1}
    ${LINK} -o sc_application_1 $(obj) ${obj_1}

sc_application_2 : ${obj} ${obj_2}
    ${LINK} -o sc_application_2 $(obj) ${obj_2}

%.o : %.cpp %.h
    ${COMPILE} -o $@ $< $(LIB_INC)

clean :
    rm sc_application_1 sc_application_2 ${obj} ${obj_1} ${obj_2}

Where lib, wrappers and processes are subdirectories of the directory where the Makefile and the two main applications sc_application_1 and sc_application_2 are stored. When I run make, I get the following output (only the last few lines w/o compiler warnings).

g++ -g -Wall -c -o lib/Scheduler.o lib/Scheduler.cpp -Ilib -Iwrappers -Iprocesses
g++ -g -Wall -c -o wrappers/consumer_wrapper.o wrappers/consumer_wrapper.cpp -Ilib -Iwrappers -Iprocesses
g++ -g -Wall -c -o wrappers/generator_wrapper.o wrappers/generator_wrapper.cpp -Ilib -Iwrappers -Iprocesses
g++ -g -Wall -c -o wrappers/square_wrapper.o wrappers/square_wrapper.cpp -Ilib -Iwrappers -Iprocesses
g++ -g -Wall -c -o processnetwork_part001.o processnetwork_part001.cpp -Ilib -Iwrappers -Iprocesses
g++ -g -Wall   -c -o sc_application_1.o sc_application_1.cpp
In file included from wrappers/wrappers.h:4:0,
                 from sc_application_1.cpp:10:
wrappers/generator_wrapper.h:4:28: fatal error: ProcessWrapper.h: No such file or directory
compilation terminated.
make: *** [sc_application_1.o] Error 1

Compilation fails because for some reason that I don’t understand, the variable LIB_INC isn’t added anymore to

g++ -g -Wall   -c -o sc_application_1.o sc_application_1.cpp

But it is (as I intended) on all previous lines. Can anyone explain me this behaviour? Thank you.

edit: The error doesn’t occur when I ommit the “%.h” in the “%.o” target.

  • 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-05-22T17:12:09+00:00Added an answer on May 22, 2026 at 5:12 pm

    I’m going to go out on a limb, and guess that there is no sc_application_1.h, but there is a header file for every previous source (e.g. Scheduler.h, consumer_wrapper.h …).

    Your %.o: %.cpp %.h rule doesn’t apply if there is no %.h, so Make falls back on its default rule, which does not use LIB_INC. The simplest way to fix this is to add another %.o rule:

    %.o : %.cpp %.h
        ${COMPILE} -o $@ $< $(LIB_INC)
    
    %.o : %.cpp
        ${COMPILE} -o $@ $< $(LIB_INC)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following makefile CXX = g++ CXXFLAGS = -c -g -pg -Wall
I have the following piece of makefile: CXXFLAGS = -std=c++0x -Wall SRCS = test1.cpp
I have used -Wall -Werror in my Makefile but I want to disable following
I have the following Makefile rules: DIR = src SOURCES = $(shell find $(DIR)
I have the following Makefile.am inside ./src where I need to generate dependencies for
I have the following makefile (fragment) SRC_DIR = src OBJ_DIR = obj DEP_DIR =
I have the following makefile: CC = gcc SRC = source1.c EXE = source1
I have the following makefile CXXFILES = pthreads.cpp CXXFLAGS = -O3 -o prog -rdynamic
I have the following makefile for my project, and I'd like to configure it
Utility: NMake Platform : Windows 7 I have the following Makefile FILE = $(shell)

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.