skip to Main Content

I am working with an ecological model PEAT-DOS-TEM. I am working in Vagrant ubuntu/trusty64 on a PC. The code I got from GitHub has a Makefile. When i run the command "make" I get this error as a result:

"make: *** No rule to make target ‘obj/TEM.o’, needed by ‘dos-tem’. Stop."

I didn’t write this makefile and I don’t know C++ very well, if you know how to help me please explain as you would to a beginner. Thank you.

Here is my Makefile:


CC=g++


CFLAGS= -c -Wall -ansi -O0 -g -fPIC 

LIBS=-lnetcdf_c++ -lnetcdf 
LIBDIR=-Lnetcdf/libs
INCLUDES=-Inetcdf/includes
SOURCES= src/TEM.o 
         src/atmosphere/AtmosUtil.o 

OBJECTS= TEM.o
        AtmosUtil.o 

GIT_SHA := $(shell git describe --abbrev=6 --dirty --always --tags)
TEMOBJ= obj/TEM.o
    

dos-tem: $(SOURCES) $(TEMOBJ)
    $(CC) -o peat-dos-tem $(OBJECTS) $(TEMOBJ) $(LIBDIR) $(LIBS)

lib: $(SOURCES) 
    $(CC) -o libDOSTEM.so -shared $(INCLUDES) $(OBJECTS) $(LIBDIR) $(LIBS)

.cpp.o:  
    $(CC) $(CFLAGS) $(INCLUDES) $<

clean:
    rm -f $(OBJECTS) DVMDOSTEM TEM.o libDOSTEM.so* *~


3

Answers


  1. Chosen as BEST ANSWER

    So, turns out the Vagrant box I was using just needed to be updated. The original code is working. Thanks for all the help.


  2. First check if you have installed c++ compiler by typing g++ in terminal.

    Than to compile type in terminal: gcc sourcefile_name.cpp -o outputfile.exe

    Finally, to run the code, type: outputfile.exe

    Hope it helped

    Login or Signup to reply.
  3. You have asked make to build a file obj/TEM.o:

    TEMOBJ= obj/TEM.o
    
    dos-tem: $(SOURCES) $(TEMOBJ)
    

    (why do you list $(SOURCES) as a prerequisite?) but you have no rule to build that file. This rule:

    .cpp.o:  
            $(CC) $(CFLAGS) $(INCLUDES) $<
    

    will tell make how to build a file X.o from a file X.cpp; in your case the X is obj/TEM so this rule only works if make can find (or build) a file named obj/TEM.cpp which it can’t.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search