Search code examples
mingw-w64dcmtk

Error compiling DCMTK from source in MinGW-w64 GCC-8.1.0 "Error: 'FlsAlloc' was not declared in this scope"


I am trying to compile DCMTK from the source through MinGW32-w64 and Cmake.

I am getting these errors after mingw32-make command:

In file included from C:/dcmtk/oflog/include/dcmtk/oflog/internal/internal.h:59,
                 from C:\Users\Rodrigo\Downloads\tmp_dcmtk\dcmtk\oflog\libsrc\oflog.cc:35:
C:/dcmtk/oflog/include/dcmtk/oflog/thread/impl/tls.h: In function 'dcmtk::log4cplus::thread::impl::tls_key_type dcmtk::log4cplus::thread::impl::tls_init(PFLS_CALLBACK_FUNCTION)':
C:/dcmtk/oflog/include/dcmtk/oflog/thread/impl/tls.h:127:12: error: 'FlsAlloc' was not declared in this scope
     return FlsAlloc(cleanupfunc);
            ^~~~~~~~
C:/dcmtk/oflog/include/dcmtk/oflog/thread/impl/tls.h:127:12: note: suggested alternative: 'TlsAlloc'
     return FlsAlloc(cleanupfunc);
            ^~~~~~~~
            TlsAlloc
C:/dcmtk/oflog/include/dcmtk/oflog/thread/impl/tls.h: In function 'void* dcmtk::log4cplus::thread::impl::tls_get_value(dcmtk::log4cplus::thread::impl::tls_key_type)':
C:/dcmtk/oflog/include/dcmtk/oflog/thread/impl/tls.h:137:12: error: 'FlsGetValue' was not declared in this scope
     return FlsGetValue(k);
            ^~~~~~~~~~~
C:/dcmtk/oflog/include/dcmtk/oflog/thread/impl/tls.h:137:12: note: suggested alternative: 'TlsGetValue'
     return FlsGetValue(k);
            ^~~~~~~~~~~
            TlsGetValue
C:/dcmtk/oflog/include/dcmtk/oflog/thread/impl/tls.h: In function 'void dcmtk::log4cplus::thread::impl::tls_set_value(dcmtk::log4cplus::thread::impl::tls_key_type, dcmtk::log4cplus::thread::impl::tls_value_type)':
C:/dcmtk/oflog/include/dcmtk/oflog/thread/impl/tls.h:148:5: error: 'FlsSetValue' was not declared in this scope
     FlsSetValue(k, value);
     ^~~~~~~~~~~
C:/dcmtk/oflog/include/dcmtk/oflog/thread/impl/tls.h:148:5: note: suggested alternative: 'TlsSetValue'
     FlsSetValue(k, value);
     ^~~~~~~~~~~
     TlsSetValue
C:/dcmtk/oflog/include/dcmtk/oflog/thread/impl/tls.h: In function 'void dcmtk::log4cplus::thread::impl::tls_cleanup(dcmtk::log4cplus::thread::impl::tls_key_type)':
C:/dcmtk/oflog/include/dcmtk/oflog/thread/impl/tls.h:159:5: error: 'FlsFree' was not declared in this scope
     FlsFree(k);
     ^~~~~~~
C:/dcmtk/oflog/include/dcmtk/oflog/thread/impl/tls.h:159:5: note: suggested alternative: 'TlsFree'
     FlsFree(k);
     ^~~~~~~
     TlsFree
mingw32-make[2]: *** [oflog\libsrc\CMakeFiles\oflog.dir\build.make:80: oflog/libsrc/CMakeFiles/oflog.dir/oflog.cc.obj] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:2533: oflog/libsrc/CMakeFiles/oflog.dir/all] Error 2
mingw32-make: *** [Makefile:157: all] Error 2

I found this link with a similar error, however, no solutions were provided.

Does anyone know how to solve this?

System:

  • Windows 10 x64
  • MinGW-W64 GCC-8.1.0
  • Gcc (i686-posix-dwarf-rev0, Built by MinGW-W64 project) 8.1.0

Solution

  • The MinGW headers do not make all of the Win32 API functions visible by default. Add a line like add_compile_definitions (_WIN32_WINNT=0x600) to CMakeLists.txt file to make the Vista and later API visible. That should fix your compilation.