I'm relatively new to cpp, so I'm not 100% sure with what I wrote here. I did some research on my error and got to a dead end.
I have a header file (I removed some of the unnecessary code to simplify):
class data_collector {
public:
data_collector();
data_collector(RestController restController , data_handler handler); //constructor
void intHandler(int dummy);
static void static_intHandler(int dummy);
private:
static data_collector instance;
}
the cpp file use the intHandler this way:
struct data_collector data_collector::instance;
data_collector::data_collector(RestController restController, data_handler handler) //constructor
{
signal(SIGINT, data_collector::static_intHandler);
}
void data_collector::intHandler(int dummy)
{
keepRunning = false;
pcieio_stop_channel(&dma_channel.dcd);
}
void data_collector::static_intHandler(int dummy)
{
data_collector::instance.intHandler(dummy);
}
signal(SIGINT, data_collector::static_intHandler);
and I recieve /projects/drive/DataServiceRT/./RFSoCControl/data_collector.h:168: undefined reference to `data_collector::instance' collect2: error: ld returned 1 exit status Makefile:3: recipe for target 'test' failed
when i try to compile and run the makefile.
I don't really know what I am doing wrong here, so if you have ideas I would appreciate it