I am getting an EXC_BAD_ACCESS, but I have no idea where. GDB is telling me:
0x000000010000664d in __gnu_cxx::new_allocator<gfx::TVec2<float> >::construct () at /usr/include/c++/4.2.1/ext/new_allocator.h:107 107 { ::new(__p) _Tp(__val); }
Any ideas?
Unknown Error
Page 1 of 14 Replies - 1049 Views - Last Post: 12 October 2010 - 06:29 AM
Replies To: Unknown Error
#2
Re: Unknown Error
Posted 11 October 2010 - 01:29 PM
So you can't figure out where it is WITH the source code, yet expect us to find out what the problem is WITHOUT it?
#3
Re: Unknown Error
Posted 11 October 2010 - 07:32 PM
So I've isolated my error. Does anyone know what this means:
Undefined symbols:
"typeinfo for Constraint", referenced from:
typeinfo for RodConstraintin RodConstraint.o
typeinfo for CircularWireConstraintin CircularWireConstraint.o
ld: symbol(s) not found
I am not looking for a coding fix, just an explanation.
Undefined symbols:
"typeinfo for Constraint", referenced from:
typeinfo for RodConstraintin RodConstraint.o
typeinfo for CircularWireConstraintin CircularWireConstraint.o
ld: symbol(s) not found
I am not looking for a coding fix, just an explanation.
#4
Re: Unknown Error
Posted 11 October 2010 - 07:50 PM
Here is more of an explanation:
I have an abstract class:
which I am extending here:
When I compile it, I get the error I specified earlier
I have an abstract class:
/* Abstract constraint class */
/* Timothy Luciani */
#include "gfx/vec2.h"
#include <vector>
#pragma once
class Constraint{
public:
virtual Vec2f *gradient() = 0;
virtual Vec2f *timeDerivative() = 0;
virtual std::vector<int> get_particle_index() = 0; // get the particle index
virtual std::vector<Vec2f> get_velocities() = 0; // get the particle velocity
virtual void draw();
};
which I am extending here:
#include "Particle.h"
#include "Constraint.h"
#include <vector>
#define EULER 0
#define SORK 1
#define FORK 2
#pragma once
class CircularWireConstraint: public Constraint{
public:
CircularWireConstraint(Particle *p, const Vec2f & center, const double radius);
void draw();
Vec2f *gradient();
// Vec2f *timeDerivative();
std::vector<int> get_particle_index();
std::vector<Vec2f> get_velocities(); // get the particle velocity
private:
Particle *m_p; // current particle
Vec2f const m_center; // center of circle
double const m_radius; // radius of circle
};
#include "CircularWireConstraint.h"
#include <GLUT/glut.h>
#define PI 3.1415926535897932384626433832795
/*--------------------------------------------------------------------
Draw Circle
--------------------------------------------------------------------*/
static void draw_circle(const Vec2f & vect, float radius)
{
glBegin(GL_LINE_LOOP);
glColor3f(0.0,1.0,0.0);
for (int i=0; i<360; i=i+18)
{
float degInRad = i*PI/180;
glVertex2f(vect[0]+cos(degInRad)*radius,vect[1]+sin(degInRad)*radius);
}
glEnd();
}
/*--------------------------------------------------------------------
Default Constructor
--------------------------------------------------------------------*/
CircularWireConstraint::CircularWireConstraint(Particle *p, const Vec2f & center, const double radius) :
m_p(p), m_center(center), m_radius(radius) {
}
/*--------------------------------------------------------------------
Draw Cirlce Constraint
--------------------------------------------------------------------*/
void CircularWireConstraint::draw() // draw the constraint circle
{
draw_circle(m_center, m_radius);
}
/*--------------------------------------------------------------------
Find the gradient
--------------------------------------------------------------------*/
Vec2f *CircularWireConstraint::gradient(){
Vec2f *gradient = new Vec2f(0.0,0.0); // create new vector
*gradient = 2 * (m_p->getVector(1,0) - m_center);
return gradient; // return gradient
}
/*--------------------------------------------------------------------
Find the time derivative
--------------------------------------------------------------------*/
Vec2f *CircularWireConstraint::timeDerivative(){
Vec2f *time = new Vec2f(0.0, 0.0);
*time = 2 * (m_p->getVector(0,1) - m_center);
return time;
}
/*--------------------------------------------------------------------
Get Particle Index
--------------------------------------------------------------------*/
std::vector<int> CircularWireConstraint::get_particle_index(){
std::vector<int> index;
index.push_back(m_p->get_particle_index()); // return the index of the particles
return index; // return the particles index
}
/*--------------------------------------------------------------------
Get Particle Index
--------------------------------------------------------------------*/
std::vector<Vec2f> CircularWireConstraint::get_velocities(){
std::vector<Vec2f> velocity; // make vector
velocity.push_back(m_p->getVector(0,1)); // add velocities
return velocity;
}
When I compile it, I get the error I specified earlier
#5
Re: Unknown Error
Posted 12 October 2010 - 06:29 AM
Please post the complete error messages. It would also help to see how you are using this class (a small compilable snippet that demonstrates the problem).
I would also suggest include guards instead of or with the #pragma once. As explained in the following link: include guards
Jim
I would also suggest include guards instead of or with the #pragma once. As explained in the following link: include guards
Jim
Page 1 of 1

New Topic/Question
Reply


MultiQuote



|