undefined reference to `MersenneRandomInit'

Hello, everyone!
Thank you for your attention to my stupid problem.
I am trying to use Mersenne Twister library from agner.org/random/
This is an example program to compile.

#include <time.h>
#include <stdio.h>
#include "randoma.h"
int main() {
int seed = time(0);
double r;
MersenneRandomInit(seed);
r = MersenneRandom();
printf("\n%f", r);
return 0;
}

I compile it:
g++ cas.cpp -o a.out
I get two typical errors for novices:
undefined reference to `MersenneRandomInit'
undefined reference to `MersenneRandom'
collect2: ld returned 1 exit status

I believe I could find the solution myself but failed to do it in several hours.
Sorry for disturbance and good luck.

Last edited on
You need to link against the library.
ok I did it using
g++ -Wall -c ./cas.cpp

g++ -Wall -g cas.o randomaelf32.a -o a.out

I am not sure if it's the best way but this works more or less correctly.
Topic archived. No new replies allowed.