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
So, turns out the Vagrant box I was using just needed to be updated. The original code is working. Thanks for all the help.
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
You have asked
make
to build a fileobj/TEM.o
:(why do you list
$(SOURCES)
as a prerequisite?) but you have no rule to build that file. This rule:will tell make how to build a file
X.o
from a fileX.cpp
; in your case theX
isobj/TEM
so this rule only works if make can find (or build) a file namedobj/TEM.cpp
which it can’t.