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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:19:21+00:00 2026-06-11T14:19:21+00:00

Have a reference makefile that im slowly editing and using which spits out these

  • 0

Have a reference makefile that im slowly editing and using which spits out these two errors

Makefile:25: warning: overriding commands for target `build/semanticHash'
Makefile:21: warning: ignoring old commands for target `build/semanticHash'
make: Circular build/semanticHash <- build/semanticHash dependency dropped.
cc -g -ldl  -lgsl -lgslcblas -lzmq  -O2 -Wall -Wextra -Isrc -rdynamic -DNDEBUG  -fPIC   -c -o src/semanticHash/rmb.o src/semanticHash/rmb.c

I’m new to makefile syntax and rules, so any common mistakes I Google for, but no luck for myself in this case.

So the question is, where am I causing these errors, and is there any patterns that I should avoid in my current makefile?

CFLAGS= -g $(LIBS) -O2 -Wall -Wextra -Isrc -rdynamic -DNDEBUG $(OPTFLAGS)
LIBS= -ldl  $(OPTLIBS)
PREFIX?=/usr/local
OPTLIBS= -lgsl -lgslcblas -lzmq 

SOURCES=$(wildcard src/**/*.c src/*.c)
OBJECTS=$(patsubst %.c,%.o,$(SOURCES))

TEST_SRC=$(wildcard tests/*_tests.c)
TESTS=$(patsubst %.c,%,$(TEST_SRC))

TARGET=build/semanticHash  # Rename to library !!!!!
SO_TARGET=$(patsubst %.a,%.so,$(TARGET))

# The Target Build
all: $(TARGET) tests


$(TARGET): CFLAGS += -fPIC
$(TARGET): build $(OBJECTS)
    ar rcs $@ $(OBJECTS)
    ranlib $@

$(SO_TARGET): $(TARGET) $(OBJECTS) 
    $(CC) -shared -o $@ $(OBJECTS) 

build:
    @mkdir -p build
    @mkdir -p bin

# The Unit Tests
.PHONY: tests
tests: CFLAGS += $(TARGET)
tests: $(TESTS)
    sh ./tests/runtests.sh

valgrind:
    VALGRIND="valgrind --log-file=/tmp/valgrind-%p.log" $(MAKE)

# The Cleaner
clean:
    rm -rf build $(OBJECTS) $(TESTS)
    rm -f tests/tests.log 
    find . -name "*.gc*" -exec rm {} \;
    rm -rf `find . -name "*.dSYM" -print`

# The Install
install: all
    install -d $(DESTDIR)/$(PREFIX)/lib/
    install $(TARGET) $(DESTDIR)/$(PREFIX)/lib/
  • 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-11T14:19:22+00:00Added an answer on June 11, 2026 at 2:19 pm

    You set SO_TARGET to the same as TARGET:

    TARGET=build/semanticHash  # Rename to library !!!!!
    SO_TARGET=$(patsubst %.a,%.so,$(TARGET))
    

    As seen TARGET does not end with .a, so nothing will be substituted making SO_TARGET the same.

    Later you have

    $(SO_TARGET): $(TARGET) $(OBJECTS) 
    

    As both SO_TARGET and TARGET are the same, you have a circular dependency.

    The other two warnings are because of this issue as well, as you have conflicting commands for the same target.

    On an unrelated note, you should not mix compiler and linker flags like you do. Compiler flags are for compilation, linker flags for linking. You should also change the order of the linker options, and place the libraries to link with after the object files. This is because the GNU linker doesn’t load libraries if there isn’t anything depending on them, and dependencies are not loaded until it loads the object files.

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

Sidebar

Related Questions

I have this C++ project which compiles using a Makefile, and sometimes when (
I have been using a makefile that I inherited from the internet for long
I have a reference application that I use to work through DDD issues, and
I have a reference to call that may or may not be there. When
So I have a reference table which stores the primary key, description and update
In C++ I have a reference to an object that wants to point back
If I have a reference to an object: var test = {}; that will
In my debug build I have a reference to a DLL that is only
I have two projects, one is a library that uses libpq headers and the
I have a Makefile.am which will be responsible for building a final application binary:

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.