Skip to Main Content

DevOps, CI/CD and Automation


For appeals, questions and feedback about Oracle Forums, please email Please ask technical questions in the appropriate category. Thank you!

Undefined symbol using static constexpr

Jacob BarrettJun 12 2017 — edited Jun 16 2017

The following code using static constexp on a class results in and undefined symbol the on the 12.5 linker but links fine in GCC, Clang and Visual C++.


class Test {


  static constexpr auto CONST_VALUE = "const value";

  static constexpr auto CONST_OTHER = "const other";



#include <iostream>

#include "test.h"

int main() {

std::cout << Test::CONST_VALUE;


When compiled:

$ CC -std=c++11 test.cpp -o test

Undefined                       first referenced

symbol                             in file

Test::CONST_VALUE              test.o

[Hint: static member Test::CONST_VALUE must be defined in the program]

Notice no compiler error is given when processing the header and that only for the variable being accessed in the cpp file gives an error at link time.


This post has been answered by Steve.Clamage-Oracle on Jun 13 2017
Jump to Answer
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 14 2017
Added on Jun 12 2017