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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:39:20+00:00 2026-05-25T09:39:20+00:00

I’ve been trying to figure this out for a little while now and I

  • 0

I’ve been trying to figure this out for a little while now and I am at the point where I am out of guesses/ideas.

I am making some C programs for a numerical analysis class at school and many of the programs use utility functions that I’ve written beforehand. I’d like to have the utility “library” in a separate directory from the class programs, but be able to include the utility header files when needed. Below is the structure of my “setup” (+ = directory/folder, – = files)

 +Code
    +Classes
         +Fall_11
              +Numerical_Programs
                  +Bisection
                      -.c and .h file(s) for bisection
                       +linux
                            -makefile
    +util
        +CompareFloats
            - CompareFloats.h

So basically, I have Bisection.c and Bisection.h within the directory Bisection. Bisection.c uses floating-point comparison functions that are within CompareFloats.h, in the util/CompareFloats directory.

Below is the makefile I’ve been trying to use:

###############################################################################
#       makefile for Bisection test                           #
###############################################################################


#--------------------------------Macros----------------------------------------#
COMPILER = gcc
UTIL = ../../../../../util/CompareFloats
FLAGS = -ggdb -Wall -lm -I$(UTIL)
OBJECTS =  ../Bisection.o ../BisectTest.o $(UTIL)/CompareFloats.o
OBJECT_DIR = ../OBJECTS
EXEC = BisectTest

all :   $(EXEC)
    test -d $(OBJECT_DIR) || mkdir $(OBJECT_DIR)
    mv $(OBJECTS) $(OBJECT_DIR)

$(EXEC) : $(OBJECTS)
      $(COMPILER) $(FLAGS) $(OBJECTS) -o $(EXEC)

#-----------------------------Dependencies--------------------------------------#
Bisection.o :       ../Bisection.h
BisectTest.o:       ../Bisection.h 
CompareFloats.o:    $(UTIL)/CompareFloats.h

clean:
    rm -f $(EXEC) *.o $(OBJECT_DIR)/*.o
    rmdir $(OBJECT_DIR)

I understand that the -I flag will allow header files to be searched for in other directories. I figured I was using it correctly, but I can’t get it to work. I just get an error that CompareFloats.h does not exist (I’ve double checked the path and it is correct). Inside Bisection.c, I have

#include "CompareFloats.h"

like usual. The only way I can get this to work is to have the #include statement contain the relative path, like

#include "../../../../util/CompareFloats/CompareFloats.h"

(it has one less ../ because Bisection.c is one level up from the makefile).

Any suggestions? I’d really like to just have #include “CompareFloats.h” instead of the relative path.

If I am not providing enough information, please let me know.

Thanks.

  • 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-25T09:39:21+00:00Added an answer on May 25, 2026 at 9:39 am

    So your problem is in the auto rule generated for Bisection.o. You can do one of two things:

    1) make a rule for the Bisection.o:

    Bisection.o :       ../Bisection.h
            gcc -c -o ../Bisection.o -I$(UTIL) ../Bisection.c 
    

    2) append the include flag -I$(UTIL) to the variable CFLAGS (these are the flags passed to the C compiler)

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

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a jquery bug and I've been looking for hours now, I can't
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is

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.