Frage

I have written complicated C and C++ makefiles in the past. However, I cannot seem to get my D makefile to work. It throws over a thousand lines of "undefined reference" errors, which look as if Phobos is failing to be linked. How can I fix that?

I am using GNU make and LDC2 on Fedora 19 Linux.

Edit: Compiling and linking directly using LDC2 works correctly. Only when invoked with 'make' is there an error. It seems that make is trying to invoke a separate linker.

Edit 2: Here is my makefile:

# This macro contains the source files
sources := $(wildcard *.d)

binaries := $(sources:%.d=%)

all: $(binaries)

%.o:%.d
        ldc2 $< -O5 -check-printf-calls

Deleting the .o fixed it.

War es hilfreich?

Lösung

I don't know the intricacies of Pattern Rules, but I believe that is where your problem lies.

%.o:%.d
    ldc2 $< -O5 -check-printf-calls

You've asked make to convert every .d file into a .o by calling the ldc2 command. However, you aren't requesting ldc2 to build object files, you're asking it to build an executable (I don't know which flag you want dmd/gdc: -c). Though I would have expected compiler errors from this before linker.

By removing the .o I must assume that Make is instead passing all the .d files at once rather than individually.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top