# Stringstream doesnt link with -std=c++14

**URL:** <https://forums.developer.nvidia.com/t/stringstream-doesnt-link-with-std-c-14/295040>\
**Category:** nvc, nvc++ and nvfortran\
**Created:** [June 3, 2024, 7:03pm UTC](https://forums.developer.nvidia.com/t/stringstream-doesnt-link-with-std-c-14/295040 "2024-06-03T19:03:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kmeagher](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@kmeagher](https://forums.developer.nvidia.com/u/kmeagher)\
**Post date:** [June 3, 2024, 7:03pm UTC](https://forums.developer.nvidia.com/t/stringstream-doesnt-link-with-std-c-14/295040/1 "2024-06-03T19:03:00Z")

</div>

With sstream.cpp:

```auto
#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:

```auto
/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.

---

<div class="post-metadata">

**Author:** ![MatColgrove](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/matcolgrove/32/14047_2.png) [@MatColgrove](https://forums.developer.nvidia.com/u/MatColgrove)\
**Post date:** [June 3, 2024, 8:07pm UTC](https://forums.developer.nvidia.com/t/stringstream-doesnt-link-with-std-c-14/295040/2 "2024-06-03T20:07:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kmeagher](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@kmeagher](https://forums.developer.nvidia.com/u/kmeagher)\
**Post date:** [June 3, 2024, 9:32pm UTC](https://forums.developer.nvidia.com/t/stringstream-doesnt-link-with-std-c-14/295040/3 "2024-06-03T21:32:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/system/32/68080_2.png) [@system](https://forums.developer.nvidia.com/u/system)\
**Post date:** [June 17, 2024, 9:33pm UTC](https://forums.developer.nvidia.com/t/stringstream-doesnt-link-with-std-c-14/295040/4 "2024-06-17T21:33:07Z")

</div>

Closed on June 17, 2024, 9:33pm UTC

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