I know this question is old, but it may be useful for someone.
A global variable (in this case MyClass inst) should not be a externcompilation unit that defines it (here A.cpp)
One way to achieve this:
- (,
global.h) * cpp, . extern , (, #ifdef):
global.h :
#ifdef A_H_
#define EXTERN
#else
#define EXTERN extern
#endif
EXTERN MyClass inst;
A.h :
#ifndef A_H_
#define A_H_
#endif
A.cpp:
#include "A.h"
#include "global.h"
, !