Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

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

    Mobile and Embedded
    2
    3
    232
    Loading More Posts
    • 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
      bogong last edited by

      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 Reply Quote 0
      • K
        koahnig @bogong last edited by koahnig

        @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 Reply Quote 1
        • B
          bogong last edited by

          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 Reply Quote 0
          • First post
            Last post