Undefined reference to functions while building

Hello!

So while working on my project I have come across a build error that I just cannot get rid of. I also can’t figure out where it’s coming from. I’ve tried various solutions that have come up online regarding similar situations but nothing has worked.

While building, I get an error: “midi_handle.cpp:(.text._ZN7polimod10MidiHandle4initEv+0x70): undefined reference to `polimod::MyDac::init()'”, even though I have included ‘dac.hpp’ in ‘midi_handle.cpp’ and checked everything for typos etc.

There’s a screenshot of the various .cpp and .hpp files involved in the situation. I have no idea how to fix this so help would be appreciated. If you need additional files/information to figure this out, let me know.

Thanks!

The implementation of dac.cpp is wrong. You use

using namespace polimod;

and then start to implement a global function called init() and writeAllChn().

This is therefor not in any way connected to the MyDac class for which the compiler complains has missing functions (it’s correct). It’s just defining the stand-alone function polimod::init(), not polimod::MyDac::init().

So, your file should e.g. be

using namespace polimod;

void MyDac::init() { /* ... */ }
void MyDac::writeAllChn(int a, int b, int c, int d) {  /* .. */}

See e.g. coding style - Correct way to define C++ namespace methods in .cpp file - Stack Overflow.

Oh dang, yeah. Made the changes, and it build succesfully Had done it correctly on previous files, must’ve had a serious brainfart.

Thanks!!

1 Like