Bug 22

Summary: last 1.1 doesnt compile for x86 Qnap NAS
Product: Orthanc Reporter: Sébastien Jodogne <s.jodogne>
Component: Orthanc CoreAssignee: Sébastien Jodogne <s.jodogne>
Status: RESOLVED FIXED    
Severity: minor    
Priority: ---    
Version: unspecified   
Hardware: All   
OS: All   

Description Sébastien Jodogne 2020-06-29 15:11:40 CEST
[BitBucket user: qoolbox]
[BitBucket date: 2016-07-19.17:42:19]

Hi i am the dev for your great apps,

i made an x86 version for 1.0 version, but since 1.1 getting the following error on make

```
-- Build files have been written to: /SRC/Orthanc-1.1.0
root@debian:/SRC/Orthanc-1.1.0# make
make: Warning: File `Makefile' has modification time 1.1e+06 s in the future
make[1]: Warning: File `CMakeFiles/Makefile2' has modification time 1.1e+06 s in the future
make[2]: Warning: File `CMakeFiles/CoreLibrary.dir/flags.make' has modification time 1.1e+06 s in the future
Scanning dependencies of target CoreLibrary
make[2]: warning:  Clock skew detected.  Your build may be incomplete.
make[2]: Warning: File `CMakeFiles/CoreLibrary.dir/flags.make' has modification time 1.1e+06 s in the future
[  0%] Building CXX object CMakeFiles/CoreLibrary.dir/Core/DicomFormat/DicomMap.cpp.o
/SRC/Orthanc-1.1.0/Core/DicomFormat/DicomMap.cpp: In function ‘uint16_t Orthanc::ReadUnsignedInteger16(const char*)’:
/SRC/Orthanc-1.1.0/Core/DicomFormat/DicomMap.cpp:479: error: ‘le16toh’ was not declared in this scope
/SRC/Orthanc-1.1.0/Core/DicomFormat/DicomMap.cpp: In function ‘uint32_t Orthanc::ReadUnsignedInteger32(const char*)’:
/SRC/Orthanc-1.1.0/Core/DicomFormat/DicomMap.cpp:485: error: ‘le32toh’ was not declared in this scope
make[2]: *** [CMakeFiles/CoreLibrary.dir/Core/DicomFormat/DicomMap.cpp.o] Error 1
make[1]: *** [CMakeFiles/CoreLibrary.dir/all] Error 2
make: *** [all] Error 2
```

any chance to fix this ?

glibc is 2.6.0 and GCC 4.3.6 (cross compilation)


command used 

```
CXX=${HOST}-g++                 \
LD=${HOST}-ld                   \
AS=${HOST}-as                   \
AR=${HOST}-ar                   \
CC=${HOST}-gcc \
PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig"  \
CFLAGS="-O2 -I$PREFIX/include " \
CXXFLAGS="-O2 -I$PREFIX/include"     \
LDFLAGS="-L$PREFIX/lib -Wl,-rpath,$PREFIX/lib" \
CPPFLAGS="-O2 -I$PREFIX/include"     \
FFLAGS="-O2 -I$PREFIX/include"     \
cmake  \
-DCMAKE_SYSTEM_NAME=Linux \
-DCMAKE_SYSTEM_PROCESSOR=x86 \
-DCMAKE_CROSSCOMPILING=1 \
-DCMAKE_C_COMPILER=/data/x-tools/i686-QNAP-linux-gnu/bin/i686-QNAP-linux-gnu-gcc \
-DCMAKE_CXX_COMPILER=/data/x-tools/i686-QNAP-linux-gnu/bin/i686-QNAP-linux-gnu-g++ \
-DCMAKE_INSTALL_PREFIX="$PREFIX" \
-DCMAKE_LIBRARY_PATH=$PREFIX/lib \
-DCMAKE_INCLUDE_PATH=$PREFIX/include \
-DCMAKE_BUILD_TYPE=Release    \
```

thanks for all
Comment 1 Sébastien Jodogne 2020-06-29 15:19:09 CEST
[BitBucket user: Sébastien Jodogne]
[BitBucket date: 2016-07-19.18:52:53]

Hello,

I thank you for your efforts to package Orthanc 1.1.0 for QNAP. Unfortunately, I don't have access to a QNAP system, so I won't be able to fix this issue by myself.

The file to be patched to have access to `le32toh()` and `le16toh()` is: https://hg.orthanc-server.com/orthanc/file/default/Core/Endianness.h

As QNAP seems to be built on the top of Linux, it is presumably sufficient to replace:
```
#!c++

#if defined(__linux__)
```
at the top of file by something looking as:
```
#!c++

#if defined(__linux__) || defined(__qnap__)
```

However, I cannot tell by myself whether the predefined macro to identify QNAP systems is actually `__qnap__`. Please let me know, I will fix the code thereafter.
Comment 2 Sébastien Jodogne 2020-06-29 15:19:10 CEST
[BitBucket user: qoolbox]
[BitBucket date: 2016-07-20.11:19:06]

Hi still getting error  

[  0%] Building CXX object CMakeFiles/CoreLibrary.dir/Core/Cache/MemoryCache.cpp.o
[  0%] Building CXX object CMakeFiles/CoreLibrary.dir/Core/Cache/SharedArchive.cpp.o
[  0%] Building CXX object CMakeFiles/CoreLibrary.dir/Core/ChunkedBuffer.cpp.o
[  0%] Building CXX object CMakeFiles/CoreLibrary.dir/Core/Compression/DeflateBaseCompressor.cpp.o
[  0%] Building CXX object CMakeFiles/CoreLibrary.dir/Core/Compression/GzipCompressor.cpp.o
[  0%] Building CXX object CMakeFiles/CoreLibrary.dir/Core/Compression/HierarchicalZipWriter.cpp.o
[  0%] Building CXX object CMakeFiles/CoreLibrary.dir/Core/Compression/ZipWriter.cpp.o
[  0%] Building CXX object CMakeFiles/CoreLibrary.dir/Core/Compression/ZlibCompressor.cpp.o
[  0%] Building CXX object CMakeFiles/CoreLibrary.dir/Core/DicomFormat/DicomArray.cpp.o
[  0%] Building CXX object CMakeFiles/CoreLibrary.dir/Core/DicomFormat/DicomMap.cpp.o
/SRC/Orthanc-1.1.0/Core/DicomFormat/DicomMap.cpp: In function ‘uint16_t Orthanc::ReadUnsignedInteger16(const char*)’:
/SRC/Orthanc-1.1.0/Core/DicomFormat/DicomMap.cpp:479: error: ‘le16toh’ was not declared in this scope
/SRC/Orthanc-1.1.0/Core/DicomFormat/DicomMap.cpp: In function ‘uint32_t Orthanc::ReadUnsignedInteger32(const char*)’:
/SRC/Orthanc-1.1.0/Core/DicomFormat/DicomMap.cpp:485: error: ‘le32toh’ was not declared in this scope
make[2]: *** [CMakeFiles/CoreLibrary.dir/Core/DicomFormat/DicomMap.cpp.o] Error 1
make[1]: *** [CMakeFiles/CoreLibrary.dir/all] Error 2
make: *** [all] Error 2


my build environment is a debian 6 x86 with my own toolchain

here is the output in Pastebin : http://pastebin.com/7P74QKJq

Thanks again...
Comment 3 Sébastien Jodogne 2020-06-29 15:19:11 CEST
[BitBucket user: Sébastien Jodogne]
[BitBucket date: 2016-07-20.11:26:23]

What modifications have you tried in https://hg.orthanc-server.com/orthanc/file/default/Core/Endianness.h
Comment 4 Sébastien Jodogne 2020-06-29 15:19:12 CEST
[BitBucket user: qoolbox]
[BitBucket date: 2016-07-20.11:29:33]

directly on the source tar.gz  ( Orthanc-1.1.0/Core/Endianness.h )
Comment 5 Sébastien Jodogne 2020-06-29 15:19:13 CEST
[BitBucket user: Sébastien Jodogne]
[BitBucket date: 2016-07-20.11:36:35]

As written in my first comment, you must adapt this file to QNAP. I cannot help you with this, as I don't have the QNAP toolchain.
Comment 6 Sébastien Jodogne 2020-06-29 15:19:14 CEST
[BitBucket user: qoolbox]
[BitBucket date: 2016-07-20.11:55:26]

seems related to GCC or LIBC version...

i am testing on a x64 ToolChain (newer GCC and libc), it compiles fine....

hope you will find the root..  1.0 was compiling fine  : http://www.forum-nas.fr/viewtopic.php?f=21&t=4647&p=30625&hilit=othanc#p30625  (french forum) for the link
Comment 7 Sébastien Jodogne 2020-06-29 15:19:15 CEST
[BitBucket user: Sébastien Jodogne]
[BitBucket date: 2016-07-20.12:03:36]

Once again, I don't have access to QNAP, so I cannot find the root without your help. Orthanc 1.1.0 compiles fine on each and every Debian architecture available (https://packages.debian.org/fr/sid/orthanc), including x86 32bit. Please get in touch with the QNAP technical support, there is something non-standard going here...
Comment 8 Sébastien Jodogne 2020-06-29 15:20:04 CEST
[BitBucket user: Sébastien Jodogne]
[BitBucket date: 2017-06-30.07:59:00]

I put this issue of hold, as no feedback from QNAP was received for about 1 year.
Comment 9 Sébastien Jodogne 2020-06-29 15:24:30 CEST
[BitBucket user: Sébastien Jodogne]
[BitBucket date: 2019-01-25.09:07:25]

No follow-up by the reporter for more than two years, closing the issue.