0

New to c++, and trying to use a file our professor made for us and I can't use any of the functions it provides heres the code that gives an Undefined reference. I didn't include the function implementations but they again were provided so they are correct. I'm using codeblocks and all three files are in my sources folder. What is causing this?

#include <iostream>

using namespace std;
#include "random.h"


int main()
{

cout<< random_instance(6,2.5,1);
return 0;
}

this is the random.h

#ifndef RANDOM_H
#define RANDOM_H

#define TWO_PI 6.2831853071795864769252866

double * random_instance( int length, const double mu, const double sigma = 1 );
double gaussian_rand( const double mu, const double sigma );

#endif /* defined(RANDOM_H) */
tokola
  • 257
  • 4
  • 13

1 Answers1

0

The definition for random_instance is missing.

You should probably compile and link random.cpp too which should contain the definitions for the functions declared in random.h, maybe something like this:

g++ path/to/main.cpp path/to/random.cpp

In Code::Blocks there's probably a section somewhere where you can choose the files to compile and link.

Emil Laine
  • 41,598
  • 9
  • 101
  • 157