Stringstream doesnt link with -std=c++14

With sstream.cpp:

#include <sstream>
#include <string>
#include <iostream>

int main(){
    std::stringstream s("ASDF zzzz ASDF");
    std::string word; 
    int count = 0;
    while (s >> word)
        count++;
    std::cout << " Number of words are: " << count << "\n";
}

when run with nvc++ sstream.cpp -std=c++14 && ./a.out

I get:

/tmp/nvc++rMufZxAT2Qig.o: In function `std::basic_streambuf<char, std::char_traits<char> >::~basic_streambuf()':
nvc++jMufB0B5wm3X.ll:(.text+0x754): undefined reference to `operator delete(void*, unsigned long)'
/tmp/nvc++rMufZxAT2Qig.o: In function `std::basic_ios<char, std::char_traits<char> >::~basic_ios()':
nvc++jMufB0B5wm3X.ll:(.text+0x994): undefined reference to `operator delete(void*, unsigned long)'
/tmp/nvc++rMufZxAT2Qig.o: In function `std::basic_ostream<char, std::char_traits<char> >::~basic_ostream()':
nvc++jMufB0B5wm3X.ll:(.text+0xb14): undefined reference to `operator delete(void*, unsigned long)'
/tmp/nvc++rMufZxAT2Qig.o: In function `std::basic_istream<char, std::char_traits<char> >::~basic_istream()':
nvc++jMufB0B5wm3X.ll:(.text+0xc94): undefined reference to `operator delete(void*, unsigned long)'
/tmp/nvc++rMufZxAT2Qig.o: In function `std::basic_iostream<char, std::char_traits<char> >::~basic_iostream()':
nvc++jMufB0B5wm3X.ll:(.text+0xe54): undefined reference to `operator delete(void*, unsigned long)'
/tmp/nvc++rMufZxAT2Qig.o:nvc++jMufB0B5wm3X.ll:(.text+0x1194): more undefined references to `operator delete(void*, unsigned long)' follow

It works fine with -std=c++11 or lower but fails with -std=c++14 or highter.

Note I don’t need to use sstream in gpu offloading I just need it to load my config files.

Do you know what g++ is installed on the system?

I gave your test a try on my system and it worked fine, so I’m guessing the problem is with the STL. In order to be object compatible, nvc++ uses the GNU g++ STL. You can configure nvc++ to use a different GNU STL by setting the flag “–gcc-toolchain” or modifying the compiler config file, localrc.

That explains it, /usr/bin/g++ is version 4.8.5. But if I run nvc++ with --gcc-toolchain=/path/to/recent/gcc/bin/g++ it works

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.