Sign in to follow this  

static methods in c++ (makefile)

This topic is 4558 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, if i wrote C/C&& Programs (on Linux Plaforms), i allways used some "just copy-paste-compile it-somehow" makefiles, i.e. i never spended much time to really understand makefiles. And exactly at this point my problem starts. the simplifyed example of my problem is the following: i have a class, where i want to use static methods of another class...I allways only get linker errors.(so i think i define them right) If i make it non static it all works. Thanx for any help :-)

Share this post


Link to post
Share on other sites
her some simplifeyed code :

//PhysikEngine.h
class PhysicEngine
{
public:
PhysicEngine();
virtual ~PhysicEngine();
static void doNothing();
.
.
.


//PhysicEngine.cpp

#include "PhysicalObject.h"
#include "PhysicEngine.h"

PhysicEngine::PhysicEngine()
{
}

PhysicEngine::~PhysicEngine()
{
}
void PhysicEngine::doNothing() {
}
.
.
.

//OpenGl class where i want to use it
void init(void)
{
PhysicEngine.doNothing();
axis.setvalue(0,0);
axis.setvalue(1,1);
axis.setvalue(2,0);
GLfloat mat_specular[] = { 1.0, 1.0,


//Makefile
RM = /bin/rm -f

C++ = g++
CCFLAGS = -I. -I/usr/X11R6/include -L/usr/X11R6/lib --verbose

LDFLAGS = -lpthread -lglut -lGLU -lGL -lm -lXi -lX11 -lXmu -lXext

clean:
@echo --- $@ ---
-$(RM) *.o core

all: PhysicEngine.h PhysicEngine.o PhysicalObject.o PointMass.o SMatrix.o Vektor.o
@echo --- $@ ---
$(C++) $(CCFLAGS) GameEngine.cc Vektor.o SMatrix.o PhysicEngine.o PhysicalObject.o PointMass.o -o GameEngine $(LDFLAGS)

Vektor.o: Vektor.cc Vektor.h
$(C++) -c $(CCFLAGS) -o Vektor.o Vektor.cc $(LDFLAGS)

SMatrix.o: SMatrix.cc SMatrix.h
$(C++) -c $(CCFLAGS) -o SMatrix.o SMatrix.cc $(LDFLAGS)

PhysicEngine.o : PhysicEngine.cpp PhysicalObject.h
$(C++) -c $(CCFLAGS) -o PhysicEngine.o PhysicEngine.cpp $(LDFLAGS)

PhysicalObject.o : PhysicalObject.cpp PointMass.h
$(C++) -c $(CCFLAGS) -o PhysicalObject.o PhysicalObject.cpp $(LDFLAGS)

PointMass.o : PointMass.cpp SMatrix.h
$(C++) -c $(CCFLAGS) -o PointMass.o PointMass.cpp $(LDFLAGS)



i removed the static in the .cpp file :
now i get the following error message :
GameEngine.cc: In function `void init()':
GameEngine.cc:22: error: parse error before `.' token
make: *** [all] Error 1

if i do it like this :
PhysicEngine e;
e.doNothing();
it works.

Share this post


Link to post
Share on other sites

This topic is 4558 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this