I am using MTRand (the Mersenne Twister random number generator from http://www.bedaux.net/mtrand/) inside a class that I have defined. And when I try to compile I get an unexpected error that I can't decode. I'm a novice c++ programmer, so any help will go a long way...
Here is the relevant portion of my code:
#include<iostream>
#include<vector>
#include<deque>
#include<cmath>
#include "./mtrand/mtrand.h"
using namespace std;
class mp{
long double store;
deque< vector<long double> > stack;
long double boundary;
long double dt;
long double time;
MTRand_open random;
long int random_seed;
public:
void initialize(long int, long double, long double);
long double get_state(); // return the state at position int
void update();
friend long double A(mp*);
friend long double D(mp*);
long double normal();
vector <long double> viewCurrent();
};
There is then a function, which, if called, sets a seed for the random number generator
void mp::initialize(long int rand_seed_input, long double bdry_in, long double dt_in){
time = 0;
dt = dt_in;
random_seed = rand_seed_input;
random.seed(random_seed);
boundary = bdry_in;
}
I just want to test if this compiles, so I create a main function that does precisely nothing:
int main(){
return 0;
}
On compile time, I get an error
Undefined symbols:
"MTRand_int32::seed(unsigned long)", referenced from:
mp::initialize(int, long, long double, long double)in ccJylsHh.o
"MTRand_int32::p", referenced from:
MTRand_int32::rand_int32() in ccJylsHh.o
MTRand_int32::rand_int32() in ccJylsHh.o
MTRand_int32::rand_int32() in ccJylsHh.o
"MTRand_int32::state", referenced from:
MTRand_int32::rand_int32() in ccJylsHh.o
"MTRand_int32::gen_state()", referenced from:
MTRand_int32::rand_int32() in ccJylsHh.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
I am not sure what this error means, and how it should be removed.
From what I understand is that MTRand can't figure out how to initialize the seed...but there is a default seeding within the class MTRand so I can't see what the problem is.