Compile in Alpine Linux Docker container

Compilation and installation of DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
gsfr
Posts: 5
Joined: Tue, 2013-09-17, 10:24
Location: Stanford, CA

Compile in Alpine Linux Docker container

#1 Post by gsfr »

I'm trying to compile and run DCMTK in a minimal Alpine Linux Docker container, which uses musl libc instead of glibc.

The unmodified source of dcmtk-3.6.1_20170228.tar.gz fails to build with the following error.

Code: Select all

/tmp/dcmtk-3.6.1_20170228 # make config-all
(cd config && make ARCH="" DESTDIR="" all)
make[1]: Entering directory '/tmp/dcmtk-3.6.1_20170228/config'
c++ -O  -D_REENTRANT -D_XOPEN_SOURCE_EXTENDED -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_BSD_COMPAT -D_OSF_SOURCE -D_POSIX_C_SOURCE=199506L -Wall  -Iinclude -I../ofstd/include -I../ofstd/libsrc -oarith arith.cc
arith.cc: In function 'void provoke_snan()':
arith.cc:323:32: error: there are no arguments to 'feenableexcept' that depend on a template parameter, so a declaration of 'feenableexcept' must be available [-fpermissive]
     feenableexcept( FE_INVALID );
                                ^
arith.cc:323:32: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
arith.cc: In function 'int test_snan(std::ostream&, const char*)':
arith.cc:350:33: error: there are no arguments to 'fedisableexcept' that depend on a template parameter, so a declaration of 'fedisableexcept' must be available [-fpermissive]
     fedisableexcept( FE_INVALID );
                                 ^
arith.cc: In instantiation of 'int test_snan(std::ostream&, const char*) [with T = float; std::ostream = std::basic_ostream<char>]':
arith.cc:572:54:   required from here
arith.cc:350:20: error: 'fedisableexcept' was not declared in this scope
     fedisableexcept( FE_INVALID );
                    ^
arith.cc: In instantiation of 'int test_snan(std::ostream&, const char*) [with T = double; std::ostream = std::basic_ostream<char>]':
arith.cc:573:56:   required from here
arith.cc:350:20: error: 'fedisableexcept' was not declared in this scope
arith.cc: In instantiation of 'void provoke_snan() [with T = float]':
arith.cc:339:58:   required from 'int test_snan(std::ostream&, const char*) [with T = float; std::ostream = std::basic_ostream<char>]'
arith.cc:572:54:   required from here
arith.cc:323:19: error: 'feenableexcept' was not declared in this scope
     feenableexcept( FE_INVALID );
                   ^
arith.cc: In instantiation of 'void provoke_snan() [with T = double]':
arith.cc:339:58:   required from 'int test_snan(std::ostream&, const char*) [with T = double; std::ostream = std::basic_ostream<char>]'
arith.cc:573:56:   required from here
arith.cc:323:19: error: 'feenableexcept' was not declared in this scope
Makefile:67: recipe for target 'arith' failed
make[1]: *** [arith] Error 1
make[1]: Leaving directory '/tmp/dcmtk-3.6.1_20170228/config'
Makefile:97: recipe for target 'config-all' failed
make: *** [config-all] Error 2
This failure can easily be reproduced with the following command:

Code: Select all

docker run -it --rm alpine sh -c "
apk add --no-cache build-base curl
cd /tmp
curl http://support.dcmtk.org/redmine/attachments/download/104/dcmtk-3.6.1_20170228.tar.gz | tar xz
cd dcmtk-*
./configure
make
"
According to the C++ reference, feenableexcept() is not part of the standard for fenv.h. It is rather an extension added by glibc for trapping floating-point exceptions.

By simply dropping the line defining HAVE_FENV_H from config/configure, I can get the code to compile and run. Obviously, this is not the proper way to do it, but it was the quickest.

Questions:
  • Is there a better way to do this?
    Is feenableexcept() actually needed or could it be removed?
    Could the check for fenv.h be expanded to include a check for feenableexcept()?
Thanks,
Gunnar

Jan Schlamelcher
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 318
Joined: Mon, 2014-03-03, 09:51
Location: Oldenburg, Germany

Re: Compile in Alpine Linux Docker container

#2 Post by Jan Schlamelcher »

We've also noticed problems regarding feenableexcept recently on OpenIndiana and are already working on a fix that detects feenableexcept with a separate configuration test and sets the respective CPU flags "by hand" instead if feenableexcept is not available. Stay tuned, I expect it to be commited during the next few days.

gsfr
Posts: 5
Joined: Tue, 2013-09-17, 10:24
Location: Stanford, CA

Re: Compile in Alpine Linux Docker container

#3 Post by gsfr »

Thanks for your response, Jan. Looking forward to trying it out soon.

Jan Schlamelcher
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 318
Joined: Mon, 2014-03-03, 09:51
Location: Oldenburg, Germany

Re: Compile in Alpine Linux Docker container

#4 Post by Jan Schlamelcher »


gsfr
Posts: 5
Joined: Tue, 2013-09-17, 10:24
Location: Stanford, CA

Re: Compile in Alpine Linux Docker container

#5 Post by gsfr »

Thanks again. Now it compiles and runs successfully on Alpine.

Jan Schlamelcher
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 318
Joined: Mon, 2014-03-03, 09:51
Location: Oldenburg, Germany

Re: Compile in Alpine Linux Docker container

#6 Post by Jan Schlamelcher »

Great!

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest