You need to actually define the static member somewhere (after the class definition). Try this:
class Foo { /* ... */ };
const int Foo::MEMBER;
int main() { /* ... */ }
That should get rid of the undefined reference.
More Related Contents:
- g++ crashed when I tried to compile a program with ONE LINE
- Undefined reference to vtable
- to_string is not a member of std, says g++ (mingw)
- g++ undefined reference to typeinfo
- GCC C++ Linker errors: Undefined reference to ‘vtable for XXX’, Undefined reference to ‘ClassName::ClassName()’
- Why vector::reference doesn’t return reference to bool?
- Omitting return statement in C++
- static_assert fails compilation even though template function is called nowhere
- invalid conversion from `void*’ to `char*’ when using malloc?
- What is the purpose of using -pedantic in the GCC/G++ compiler?
- DSO missing from command line [duplicate]
- Which C++ standard is the default when compiling with g++?
- openCV program compile error “libopencv_core.so.2.4: cannot open shared object file: No such file or directory” in ubuntu 12.04
- “not declared in this scope” error with templates and inheritance [duplicate]
- Why can’t g++ find iostream.h?
- constexpr initializing static member using static function
- g++ does not show a ‘unused’ warning
- C++ compile time error: expected identifier before numeric constant
- Code runs perfect in g++ but not in Xcode – Cannot find File
- g++ variable size array no warning?
- Compiling with g++ using multiple cores
- request for member `…’ is ambiguous in g++
- “undefined reference to” using ‘g++’ to compile a C++ program
- Vscode g++ it isn’t finding .cpp definition files
- Install gcc on linux with no root privilege
- C++ template function compiles in header but not implementation
- constexpr not working if the function is declared inside class scope
- Can I make GCC warn on passing too-wide types to functions?
- get part of std::tuple
- std::array with aggregate initialization on g++ generates huge code