I have two source files, in one of them there's a static member from my own class, foo. When I compile it to an object file, the compiler generates a .ctors section, and within it, a function that calls the constructor, lets call it _GLOBAL__SUB_I_FOO.
In the second source file, I try to call this constructor myself:
int _GLOBAL__SUB_I_FOO();
int bar(){
_GLOBAL__SUB_I_FOO();
}
And when I'm linking those two objects, there's an undefined reference to _GLOBAL__SUB_I_FOO from the second file. When I'm linking using --relocatable to view what went wrong, I can see that the original constructor was renamed to _GLOBAL__SUB_I_FOO_0 to avoid the "collision" (which is intentional). What can I do to fix it? I'm using gcc 7.3.0