Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. Error using qEndian

Error using qEndian

Scheduled Pinned Locked Moved Solved C++ Gurus
4 Posts 2 Posters 1.1k 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.
  • Please_Help_me_DP Offline
    Please_Help_me_DP Offline
    Please_Help_me_D
    wrote on last edited by
    #1

    Hi,

    I have the following situation.
    I open QFile, then using memory mapping I read some bytes, reinterpret it as quint32 and change the Endianness. The problem is that I only can use qFromLittleEndian but when I change it to qFromBigEndian it gives me errors:

    • readfile.obj:-1: error: LNK2019: unresolved external symbol "unsigned int * __cdecl qbswap<unsigned int *>(unsigned int *)" (??$qbswap@PEAI@@YAPEAIPEAI@Z) referenced in function "unsigned int * __cdecl qFromBigEndian<unsigned int *>(unsigned int *)" (??$qFromBigEndian@PEAI@@YAPEAIPEAI@Z)

    • debug\ReadFile.exe:-1: error: LNK1120: 1 unresolved externals

    My code is:

    qFile = new QFile(myFile);
    segySize = qFile->size();
    quint32* memFile_quint32 = qFromBigEndian(reinterpret_cast<quint32*>(qFile->map(3600, qFile->size()-3600)));
    

    If I change qFromBigEndian to qFromLittleEndian then I have no problems. But my file is in big endian :)
    Does anybody know what it maight be?
    I use Windows 10 x64, MSVC x64, Qt 5.14.0

    kshegunovK 1 Reply Last reply
    0
    • Please_Help_me_DP Please_Help_me_D

      Hi,

      I have the following situation.
      I open QFile, then using memory mapping I read some bytes, reinterpret it as quint32 and change the Endianness. The problem is that I only can use qFromLittleEndian but when I change it to qFromBigEndian it gives me errors:

      • readfile.obj:-1: error: LNK2019: unresolved external symbol "unsigned int * __cdecl qbswap<unsigned int *>(unsigned int *)" (??$qbswap@PEAI@@YAPEAIPEAI@Z) referenced in function "unsigned int * __cdecl qFromBigEndian<unsigned int *>(unsigned int *)" (??$qFromBigEndian@PEAI@@YAPEAIPEAI@Z)

      • debug\ReadFile.exe:-1: error: LNK1120: 1 unresolved externals

      My code is:

      qFile = new QFile(myFile);
      segySize = qFile->size();
      quint32* memFile_quint32 = qFromBigEndian(reinterpret_cast<quint32*>(qFile->map(3600, qFile->size()-3600)));
      

      If I change qFromBigEndian to qFromLittleEndian then I have no problems. But my file is in big endian :)
      Does anybody know what it maight be?
      I use Windows 10 x64, MSVC x64, Qt 5.14.0

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by
      #2

      Ehm, apply to each data field, not on an array. Something like:

      quint32 * src = reinterpret_cast<quint32*>(qFile->map(3600, qFile->size()-3600));
      
      constexpr size_t elements = 3600 / sizeof(quint32);
      quint32 memFile_quint32[elements] ;
      
      for (size_t i = 0; i < elements; i++)
          memFile_quint32[i] = qFromBigEndian(src[i]);
      

      Read and abide by the Qt Code of Conduct

      Please_Help_me_DP 1 Reply Last reply
      4
      • kshegunovK kshegunov

        Ehm, apply to each data field, not on an array. Something like:

        quint32 * src = reinterpret_cast<quint32*>(qFile->map(3600, qFile->size()-3600));
        
        constexpr size_t elements = 3600 / sizeof(quint32);
        quint32 memFile_quint32[elements] ;
        
        for (size_t i = 0; i < elements; i++)
            memFile_quint32[i] = qFromBigEndian(src[i]);
        
        Please_Help_me_DP Offline
        Please_Help_me_DP Offline
        Please_Help_me_D
        wrote on last edited by
        #3

        @kshegunov thank you!
        But why it works if use qFromLittleEndian?
        Is that beacause my computer native is little endian?

        kshegunovK 1 Reply Last reply
        0
        • Please_Help_me_DP Please_Help_me_D

          @kshegunov thank you!
          But why it works if use qFromLittleEndian?
          Is that beacause my computer native is little endian?

          kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on last edited by
          #4

          @Please_Help_me_D said in Error using qEndian:

          Is that beacause my computer native is little endian?

          Yes.

          Read and abide by the Qt Code of Conduct

          1 Reply Last reply
          3

          • Login

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