duplicate symbol __Z7CONTROLSs12CONTROL_TYPEff
This usually happens when you define an inline function in a header file, but neglect to declare it with inline
keyword.
Why, in theory, should optimization levels change the linker output?
When you build with optimization, the compiler actually does inline the function, and doesn't emit "out of line" definition, resulting in successful link.
You can verify this by running nm main.o | grep __Z7CONTROLSs12CONTROL_TYPEff
-- with optimization on, I expect no output.
how I can remedy this problem
Add missing inline
, or move the definition of the function out of header file, and into a regular C++ source.