I'm messing around with g++ in Ubuntu at the moment, and I'm having trouble getting my project to compile. I'm also messing around with the boost libraries, and trying to just in general learn C++.
I have a 3 classes called shapeObject, matrix4D, and decompose. Each one is in a separate cpp file of the same name.
matrix4D.cpp has this at the top:
#include <boost/numeric/ublas/matrix.hpp>
using namespace boost::numeric::ublas;
struct matrix4D
{
... followed by code
shapeObject.cpp has this at the top:
#include <iostream>
#include <fstream>
#include <boost/numeric/ublas/matrix.hpp>
#include "matrix4D.cpp"
using namespace std;
using namespace boost::numeric::ublas;
class shapeObject
{
... followed by code
And decompose has:
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/foreach.hpp>
#include <boost/lambda/lambda.hpp>
#include "shapeObject.cpp"
#include "matrix4D.cpp"
using namespace std;
using namespace boost::numeric::ublas;
using namespace boost::lambda;
class decompose
{
... followed by code
Typing g++ matrix4D.cpp shapeObject.cpp compiles just fine. However, adding decompose.cpp as well creates a ton of errors. Some might be legitimate, but others confuse me, such as
matrix4D.cpp:3: error: redefinition of ?struct matrix4D?
This only occurs after compiling in all classes together. This leads me to believe there is something wrong with my include statements. I know of the concept in C of the header file, but I'm not sure how to use it or if it's what I need to do to fix my problem.
I have a 3 classes called shapeObject, matrix4D, and decompose. Each one is in a separate cpp file of the same name.
matrix4D.cpp has this at the top:
#include <boost/numeric/ublas/matrix.hpp>
using namespace boost::numeric::ublas;
struct matrix4D
{
... followed by code
shapeObject.cpp has this at the top:
#include <iostream>
#include <fstream>
#include <boost/numeric/ublas/matrix.hpp>
#include "matrix4D.cpp"
using namespace std;
using namespace boost::numeric::ublas;
class shapeObject
{
... followed by code
And decompose has:
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/foreach.hpp>
#include <boost/lambda/lambda.hpp>
#include "shapeObject.cpp"
#include "matrix4D.cpp"
using namespace std;
using namespace boost::numeric::ublas;
using namespace boost::lambda;
class decompose
{
... followed by code
Typing g++ matrix4D.cpp shapeObject.cpp compiles just fine. However, adding decompose.cpp as well creates a ton of errors. Some might be legitimate, but others confuse me, such as
matrix4D.cpp:3: error: redefinition of ?struct matrix4D?
This only occurs after compiling in all classes together. This leads me to believe there is something wrong with my include statements. I know of the concept in C of the header file, but I'm not sure how to use it or if it's what I need to do to fix my problem.
