Error using qEndian
-
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 -
-
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]);
-
@kshegunov thank you!
But why it works if use qFromLittleEndian?
Is that beacause my computer native is little endian? -
@Please_Help_me_D said in Error using qEndian:
Is that beacause my computer native is little endian?
Yes.