I have written the following code:
if (fileEndian == "Little"){
for(quint32 i = 0; i < nTrc; i++){
FFID(i) = *util::bit_cast<qint32*>(qFromLittleEndian(qFile->map(3608+i*bytesPerTrc, 1)));
}
} else if (fileEndian == "Big"){
for(quint32 i = 0; i < nTrc; i++){
FFID(i) = *util::bit_cast<qint32*>(qFromBigEndian(qFile->map(3608+i*bytesPerTrc, 1)));
}
}
It gives me errors:
readsegy.obj:-1: ошибка: LNK2019: unresolved external symbol "unsigned char * __cdecl qbswap<unsigned char *>(unsigned char *)" (??$qbswap@PEAE@@YAPEAEPEAE@Z) referenced in function "unsigned char * __cdecl qFromBigEndian<unsigned char *>(unsigned char *)" (??$qFromBigEndian@PEAE@@YAPEAEPEAE@Z)
debug\ReadSegy.exe:-1: ошибка: LNK1120: 1 unresolved externals
The compilator output:
jom: C: \ Users \ tasik \ Documents \ Qt_Projects \ build-ReadSegy-Desktop_x86_windows_msvc2017_pe_64bit-Debug \ Makefile.Debug [debug \ ReadSegy.exe] Error 1120
jom: C: \ Users \ tasik \ Documents \ Qt_Projects \ build-ReadSegy-Desktop_x86_windows_msvc2017_pe_64bit-Debug \ Makefile [debug] Error 2
19:05:31: The process "C: \ Qt \ Tools \ QtCreator \ bin \ jom.exe" ended with code 2.
Error during assembly / deployment of ReadSegy project (bundle: Desktop (x86-windows-msvc2017-pe-64bit))
During the execution of the "Assembly"
Actually the problem was that I didn't know the line which throws these errors but by intuation I just commented the BigEndian part of the code and it works:
if (fileEndian == "Little"){
for(quint32 i = 0; i < nTrc; i++){
FFID(i) = *util::bit_cast<qint32*>(qFromLittleEndian(qFile->map(3608+i*bytesPerTrc, 1)));
}
} else if (fileEndian == "Big"){/*
for(quint32 i = 0; i < nTrc; i++){
FFID(i) = *util::bit_cast<qint32*>(qFromBigEndian(qFile->map(3608+i*bytesPerTrc, 1)));
}*/
}
I use little endian Windows 10 x64, Qt 5.14.0, MSVC 2017 x64.
Why do I can use qFromLittleEndian but I can't qFromBigEndian??
By the way the endian of my file is LITTLE now
I think I just found a solution. If I change the order of performing bit_cast and qFromBigEndian it works:
if (fileEndian == "Little"){
for(quint32 i = 0; i < nTrc; i++){
FFID(i) = qFromLittleEndian(*util::bit_cast<qint32*>(qFile->map(3608+i*bytesPerTrc, 1)));
}
} else if (fileEndian == "Big"){
for(quint32 i = 0; i < nTrc; i++){
FFID(i) = qFromBigEndian(*util::bit_cast<qint32*>(qFile->map(3608+i*bytesPerTrc, 1)));
}
}
I don't understand why but that works fine