I am having problem building my program. Below is the makefile.
This is the error I get
make -f raytrac.mk raytrac
g++ -I../../../ -O3 -Wno-non-template-friend -Wno-deprecated -DNDEBUG ../../../libs/main/raytrac_main.cpp -o raytrac
In file included from ../../../tomso/string/string.hpp:2669:0,
from ../../../tomso/optparse/parseel.hpp:32,
from ../../../tomso/optparse/parsing.hpp:27,
from ../../../libs/main/raytrac_main.cpp:185:
../../../tomso/string/impl/string.ipp:39:21: fatal error: vect2.hpp: No such file or directory
compilation terminated.
make: *** [raytrac] Error 1
One of the problem lies in the main program. The following is the include directives in the main program
All header files are organised in the directory tomso.
> cat Makefile
OPSYS = $(shell uname -s )
TARGET = raytrac
ROOTDIR = ../../..
INCDIR = $(ROOTDIR)/tomso
SRCDIR = $(ROOTDIR)/libs
MAINDIR = $(SRCDIR)/main
OBJDIR = $(ROOTDIR)/tools/release/obj
BINDIR = $(ROOTDIR)/tools/release/bin
# ***************************************************************** #
# C++ compiler
CPP_COMP = g++
# C++ compiler options
CPP_OPTS = -I$(ROOTDIR)/ -O3 -Wno-non-template-friend -Wno-deprecated -DNDEBUG
# ***************************************************************** #
# Directories
LIBINC = $(INCLDIR)/linear_algebra/vector.hpp \
$(INCLDIR)/linear_algebra/matrix.hpp \
$(INCLDIR)/raytrace/layer.hpp \
$(INCLDIR)/raytrace/velmod.hpp
LIBSRC = $(SRCDIR)/vect.cpp \
$(INCLDIR)/linear_algebra/impl/vector.ipp \
$(INCLDIR)/linear_algebra/impl/matrix.ipp \
$(SRCDIR)/string/sstring.cpp \
$(SRCDIR)/raytrace/layer.cpp \
$(SRCDIR)/raytrace/layint_linear.cpp \
$(SRCDIR)/raytrace/laymod_linear.cpp \
$(SRCDIR)/raytrace/velmod.cpp
# ***************************************************************** #
.PHONY : help
# ***************************************************************** #
$(TARGET) : $(MAINDIR)/raytrac_main.cpp
$(CPP_COMP) $(CPP_OPTS) $(MAINDIR)/raytrac_main.cpp -o raytrac
-mv $(TARGET) $(BINDIR)
# ***************************************************************** #
help :
@echo ""
@echo "USAGE: "
@echo ""
@echo " make -f raytrac.mk To get this listing"
@echo " make -f raytrac.mk help To get this listing"
@echo " make -f raytrac Builds raytrac"
@echo " make -f nraypk.mk list List details of building raytrac"
@echo " make -f nraypk.mk clean Remove *.o and executable"
@echo ""
#___________________________________________________________________#
---------- Post updated at 04:58 PM ---------- Previous update was at 02:20 PM ----------
I have separated a template as follows
tomso/linear-algebra/vector.hpp
template declarations
tomso/linear-algebra/impl/vector.ipp
template and inline implementations
libs/linear-algebra/vector.cpp
Remaining implementations
#ifndef VECTOR_HPP
#define VECTOR_HPP
#include <assert.h>
#include <cmath>
#include <iostream>
#include "tomso/numeric/numeric.hpp"
template <class T>
class Vector {
protected:
int Size; ///< Number of elements of the vector
T* X; ///< Vector container object
public:
Vector (
): Size(0) { }
Vector (
const int n
);
Vector (
const int n,
const T v
);
etc ...
};
#include "tomso/linear_algebra/impl/vector.ipp"
#endif // VECTOR_HPP
As you see I add the implementation file vector.ipp at the end
My question is whether I neen to put the includes in vector.ipp as well.
> cat vector.ipp
#include <assert.h>
#include <cmath>
#include <iostream>
#include "tomso/numeric/numeric.hpp"
template <class T>
inline Vector<T>::Vector(
const int n
) {
Size = n;
X = new T;
for (int i = 0; i < Size; i++) {
X = 0;
}
}
etc ...