static const in c++ class: undefined reference
I have a class for local use only (i.e., its cope is only the c++ file it is defined in) class A { public: static const int MY_CONST = 5; }; void fun( int b ) { int j = A::MY_CONST; // no problem int k = std::min<int>( A::MY_CONST, b ); // link error: // undefined reference to `A::MY_CONST` } All the code reside in the same c++ file. When compiling using VS on windows, there is no problem at all. However, when compiling on Linux I get the undefined reference error only for the second statement. Any suggestions? std::min<int> 's arguments are both const int& (not just int ), i.e. references to