Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Undefined symbol when referencing std::getline with -std=c++11

dhaneyApr 30 2014 — edited May 2 2014

I'm attempting to compile the following test application:

#include <string>

#include <iostream>

int main(void) {

    std::string s;

    std::getline(std::cin, s);

    std::cout << s << std::endl;

    return 0;

}

When compiled with:

CC -std=c++03 -m64 getline.cpp

Everything is fine, however when compiled with:

CC -std=c++11 -m64 getline.cpp

I'm seeing the following linker failure:

Undefined                       first referenced

symbol                             in file

std::getline<char, std::char_traits<char>, std::allocator<char> > getline.o

ld: fatal: symbol referencing errors. No output written to a.out

Is there something additional needed on the compilation line when linking with C++11?

This post has been answered by Steve.Clamage-Oracle on Apr 30 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 30 2014
Added on Apr 30 2014
4 comments
2,520 views