Skip to content

Makefile incorrectly includes header files (*.h) as compilation sources #4

Description

@taejun-song

I encountered a build error when compiling RIsearch1 due to the inclusion of *.h files in the Makefile's targets. The default rule:

RIsearch: *.c *.h
	$(CC) $(CFLAGS) -O3 $^ -DRISVERSION=1 -lm -o $@

causes the compiler to fail with:

clang: error: cannot specify -o when generating multiple output files
make: *** [RIsearch] Error 1

This happens because header files (e.g., fasta.h) are not valid input files for the linker, yet they are included via the *.h glob and expanded into $^.

✅ Suggested Fix

A more portable and correct Makefile would explicitly list only the source files (*.c) as dependencies:

CFLAGS += -Wall -pedantic
SRC := dsm.c fasta.c risearch.c weights.c

all: RIsearch RIsearch.dbg

RIsearch: $(SRC)
	$(CC) $(CFLAGS) -O3 $(SRC) -DRISVERSION=1 -lm -o RIsearch

RIsearch.dbg: $(SRC)
	$(CC) $(CFLAGS) -g -O0 -DRISVERSION=1 -DDEBUG -DVERBOSE=2 $(SRC) -lm -o RIsearch.dbg

.PHONY: clean

clean:
	rm -f RIsearch RIsearch.dbg *.o

This avoids passing headers to the linker and allows the build to complete cleanly.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions