Home Help Center

would like to use make -j 3

ecdowneyecdowney Member Elwood DowneyOrganization: University of ArizonaProject: Large Binocular Telescope Interferometer

I have a simple Makefile that works fine with serial make (make) but not when I try to add some parallelling (make -j 3). Is there a way to make it work? Below are the particulars. This is on Centos 6.7 i386. Thanks!

The Makefile:

ICEPATH = /usr/bin ICEINCLUDE = -I. -I/usr/include CC = g++ CLDFLAGS = -g -pthread CFLAGS = -ffast-math -Wall -O2 $(CLDFLAGS) OBJS = IIFServer.o Factory.o libiif.a: $(OBJS) ar rv [email protected] $(OBJS) ranlib [email protected] IIFServer.o: IIFServer.ice $(ICEPATH)/slice2cpp IIFServer.ice $(CC) $(ICEINCLUDE) $(CFLAGS) -c IIFServer.cpp -o [email protected] Factory.o: Factory.ice $(ICEPATH)/slice2cpp Factory.ice $(CC) $(ICEINCLUDE) $(CFLAGS) -c Factory.cpp -o [email protected] clean: touch x.o rm -f *.o libiif.a IIFServer.cpp IIFServer.h Factory.cpp Factory.h

Runs fine normally:

# make /usr/bin/slice2cpp IIFServer.ice g++ -I. -I/usr/include -ffast-math -Wall -O2 -g -pthread -c IIFServer.cpp -o IIFServer.o /usr/bin/slice2cpp Factory.ice g++ -I. -I/usr/include -ffast-math -Wall -O2 -g -pthread -c Factory.cpp -o Factory.o ar rv libiif.a IIFServer.o Factory.o ar: creating libiif.a a - IIFServer.o a - Factory.o ranlib libiif.a #

But gets all confused with -j 3:

# make -j 3 /usr/bin/slice2cpp IIFServer.ice /usr/bin/slice2cpp Factory.ice g++ -I. -I/usr/include -ffast-math -Wall -O2 -g -pthread -c Factory.cpp -o Factory.o In file included from ./Factory.h:38, from Factory.cpp:21: ./IIFServer.h:21:1: error: unterminated #ifndef g++ -I. -I/usr/include -ffast-math -Wall -O2 -g -pthread -c IIFServer.cpp -o IIFServer.o In file included from Factory.cpp:21: ./Factory.h:53: error: expected unqualified-id before 'namespace' Factory.cpp:1750: error: expected '}' at end of input In file included from ./Factory.h:38, from Factory.cpp:21: ./IIFServer.h:6894: error: expected unqualified-id at end of input ./IIFServer.h:6894: error: expected '}' at end of input ./IIFServer.h:6894: error: expected '}' at end of input make: *** [Factory.o] Error 1 make: *** Waiting for unfinished jobs.... #


  • xdmxdm La Coruña, SpainAdministrators, ZeroC Staff Jose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff


    Your Makefile dependency graph is incomplete, make needs a complete dependency graph in order to figure what targets can be build in parallel.

    slice2cpp has a --depend option that outputs Makefile style dependencies and is handy to get the Slice file dependencies.

    Here is a sample Makefile that works with parallel make:

    SLICE2CPP   = slice2cpp
    CPPFLAGS    = -I.
    SLICE_SRCS  = Factory.ice \
    GEN_SRCS    = $(SLICE_SRCS:.ice=.cpp)
    GEN_HEADERS = $(SLICE_SRCS:.ice=.h)
    OBJS        = $(GEN_SRCS:.cpp=.o)
    LIBNAME     = libiif.a
    %.h: %.ice
        @mkdir -p .depend
        $(SLICE2CPP) --depend $(SLICE2CPPFLAGS) $< > .depend/$(*F).ice.d
    %.cpp: %.h
        @echo $(>F)
    %.o: %.cpp
        $(CC) $(CPPFLAGS) -c $(<F) -o [email protected]
    $(LIBNAME): $(OBJS)
        ar rv [email protected] $(OBJS)
    all: $(LIBNAME)
        rm -rf $(GEN_SRCS) $(GEN_HEADERS) $(LIBNAME) *.o
    # Include dependency files if exists
    -include $(wildcard .depend/*.d)
    # Force all non existing objs to depend on generated
    # sources, so we get dependencies right.
    $(filter-out $(wildcard  $(OBJS)), $(OBJS)): $(GEN_SRCS)

    I should mention that this sample doesn't handle C++ source dependencies, you should look into that if you want your builds to work correctly.

Sign In or Register to comment.