Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Android: undefined reference on std::ostringstream. Why?
Forum Update on Tuesday, May 27th 2025

Android: undefined reference on std::ostringstream. Why?

Scheduled Pinned Locked Moved Solved Mobile and Embedded
3 Posts 2 Posters 523 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bogong
    wrote on 28 Apr 2021, 09:41 last edited by
    #1

    Hello all!
    I have this pice of code:

    std::ostringstream oStringStream;
    oStringStream << std::this_thread::get_id();
    std::string oThreadIDString = oStringStream.str();
    const char* oThreadID = oThreadIDString.c_str();
    

    It's working perfectly for iOS and MacOS but for Android I have this error:

    error: error: undefined reference to 'std::__ndk1::basic_ostream<char, std::__ndk1::char_traits<char> >& std::__ndk1::operator<< <char, std::__ndk1::char_traits<char> >(std::__ndk1::basic_ostream<char, std::__ndk1::char_traits<char> >&, std::__ndk1::__thread_id)'
    

    Why is that? What am I missing?

    K 1 Reply Last reply 28 Apr 2021, 09:50
    0
    • B bogong
      28 Apr 2021, 09:41

      Hello all!
      I have this pice of code:

      std::ostringstream oStringStream;
      oStringStream << std::this_thread::get_id();
      std::string oThreadIDString = oStringStream.str();
      const char* oThreadID = oThreadIDString.c_str();
      

      It's working perfectly for iOS and MacOS but for Android I have this error:

      error: error: undefined reference to 'std::__ndk1::basic_ostream<char, std::__ndk1::char_traits<char> >& std::__ndk1::operator<< <char, std::__ndk1::char_traits<char> >(std::__ndk1::basic_ostream<char, std::__ndk1::char_traits<char> >&, std::__ndk1::__thread_id)'
      

      Why is that? What am I missing?

      K Offline
      K Offline
      koahnig
      wrote on 28 Apr 2021, 09:50 last edited by koahnig
      #2

      @bogong

      That is actually not Qt problem as it looks.

      Whatever the return value of get_id() is. Assign it to a variable and output this. My guess is that there is a different declaration which is actually different from standard types, but other compilers are not as "nervous".

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      1
      • B Offline
        B Offline
        bogong
        wrote on 3 May 2021, 18:14 last edited by
        #3

        Solution found.

        QString oThreadIDString = QString("0x%1");
        QString oThreadIDValue = oThreadIDString.arg((long)QThread::currentThread(),0,16);
        std::string oThreadIDStdString = oThreadIDValue.toStdString();
        
        1 Reply Last reply
        0

        1/3

        28 Apr 2021, 09:41

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved