vendredi 3 mars 2017

Generic Makefile disregarding variables

C++ project with a directory structure and Makefile styled after this blog post a simple c plus plus project structure. However, in the modified output from running makefile the variables do not seem to carry values through the compilation process.

Makefile

HOST_COMPILER := g++ #c++ 
SRCDIR := src
BUILDDIR := build
TARGET := bin/runner
SRCEXT := cc
SOURCES := $(shell find $(SRCDIR) -type f -name "*.$(SRCEXT)")
OBJECTS := $(patsubst ($SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.$(SRCEXT)=.o))

# internal flags
CFLAGS := -std=c++11 -Wall -g -fopenmp 
MAGICKFLAGS := `Magick++-config --cxxflags --cppflags --ldflags --libs`

INCLUDES := -I/usr/include/ImageMagick-6 
LIBRARIES := -L/usr/local/lib/  -lMagick++-6.Q16 -lMagick++

$(TARGET) : $(OBJECTS)
    @echo " Linking..."
    @echo " $(HOST_COMPILER) $^ -o $(TARGET) $(LIBRARIES)"
    $(HOST_COMPILER) $^ -o $(TARGET) $(LIBRARIES)

$(BUILDDIR)/%.o : $(SRCDIR)/%.$(SRCEXT)
    @mkdir -p $(BUILDDIR)
    @echo " $(HOST_COMPILER) $(CFLAGS) $(MAGICKFLAGS) $(INCLUDES)  -c -o $@ $<"
    $(HOST_COMPILER) $(CFLAGS) $(MAGICKFLAGS) $(INCLUDES) -c -o $@ $<

clean:
    @echo " Cleaning ...";
    @echo " rm -r $(BUILDDIR) $(TARGET) " ; rm -r $(BUILDDIR) $(TARGET)

Then (note the complaint about missing flag -std=c++11, yet that is defined and included $(CFLAG)).

$ make
g++    -c -o src/contour-tracing.o src/contour-tracing.cc
g++    -c -o src/opposite_spot_removal.o src/opposite_spot_removal.cc
g++    -c -o src/connected.o src/connected.cc
g++    -c -o src/main.o src/main.cc
In file included from /usr/include/c++/5/tuple:35:0,
                 from src/main.cc:3:
/usr/include/c++/5/bits/c++0x_warning.h:32:2: error:
 #error This file requires compiler and library support for the ISO C++ 2011 standard.
 This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
         #error This file requires compiler and library support \
          ^
        src/main.cc:40:6: error: ‘tuple’ in namespace ‘std’ does not name a template type
         std::tuple<unsigned int,unsigned int> getDimensions(Image image){
              ^
        <builtin>: recipe for target 'src/main.o' failed
        make: *** [src/main.o] Error 1

Aucun commentaire:

Enregistrer un commentaire