Hello, I’m trying to streamline some of my code and so decided to use common/repetitive code as
helper/wrapper functions.
However I’m getting multiple definition errors.
for instance I have a wrapper for ofRandomuf inside a Utility.h…
code in Utility.h
#ifndef __UTILITY_H__
#define __UTILITY_H__
#include "ofMain.h"
namespace Utility
{
float of_Randomuf(int seed)
{
ofSeedRandom(seed) ;
return ofRandomuf() ;
}
float of_Randomf(int seed)
{
ofSeedRandom(seed) ;
return ofRandomf() ;
}
}
#endif
and then I include Utility.h in testApp.h
but I get errors when i try and use this like:
Utility::of_Randomuf( seed ) ;
I’m sure I’m missing something trivial here??
Edit: here’s the error messege:
/usr/bin/ld: error: obj/x86_64Release/src/testApp.o: multiple definition of 'Utility::of_Randomuf(int)'
/usr/bin/ld: obj/x86_64Release/src/main.o: previous definition here
/usr/bin/ld: error: obj/x86_64Release/src/testApp.o: multiple definition of 'Utility::of_Randomf(int)'
/usr/bin/ld: obj/x86_64Release/src/main.o: previous definition here
collect2: ld returned 1 exit status
make: *** [bin/helperTest] Error 1