kindly help me to resolve this error. I have a function inside a namespace in my header file . This is my header file

#ifndef _MATPACK_H_
#define _MATPACK_H_

//-----------------------------------------------------------------------------//

#include "scene.h"     // class Scene
#include "mpmatrix3d.h"    // 3d matrix template classes
#include "vector.h"    // vector and matrix classes
#include "mpspecfun.h"     // special function prototypes
#include "mpstatistics.h"  // statistics function prototypes
#include "mproots.h"       // roots and minimum finding function prototypes
#include "mpphysics.h"     // physics related function prototypes
#include "mpdataformat.h"  // I/O data format functions
#include "mp2dplots.h"     // 2D graphics functions
#include "mp3dplots.h"     // 3D graphics functions
#include "mprandom.h"      // random number generators
#include "mpaxis.h"


namespace MATPACK {

//-----------------------------------------------------------------------------//
// differential equations
//-----------------------------------------------------------------------------//

int ODE_Bulirsch (double& x, Vector& y, 
          void (*Function) (double x, Vector& y, Vector& f), 
          double xend, double& h, double hmax, 
          double eps_abs, double eps_rel, int max_fct,
          int start, Vector* aux, int& row, double& x0);

//-----------------------------------------------------------------------------//
// integration
//-----------------------------------------------------------------------------//

double AdaptiveSimpson (double a, double b, 
            double (*funct)(double x), 
            double eps);



//-----------------------------------------------------------------------------//
// geometry
//-----------------------------------------------------------------------------//

double MpTriangleArea (double a, double b, double c, int &error);


} // namespace MATPACK


//-----------------------------------------------------------------------------//

#endif

now in my program when I tried to call MpTriangleArea() I got the following error

undefined reference to `MATPACK::MpTriangleArea(double, double, double, int&)'

please help me to rectify it

Member Avatar for r.stiltskin

Where is the body of the function?

That is a linking error. You need to either link to the library, ie

g++ yourfile.cpp -l lTheLibrary

or actually compile the source along with yours (if you have it)

g++ yourfile.cpp TheFileTheFunctionIsIn.cpp

Unfortunately, this sounds like a big set of libraries and they are usually horribly documented, so you may have to do a bit of googling/greping.

Also, please use code tags when you post code.

Hope that helps.

Dave

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.