single dcmtk.dll

Compilation and installation of DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
csmeso
Posts: 17
Joined: Mon, 2006-06-19, 15:21

single dcmtk.dll

#1 Post by csmeso »

In the november 2012 snapshot, you stated that now it is possible to build a single dcmtk.dll. I tried this, also with the latest snapshot dcmtk-8f6a406 downloaded today, but it doesnt work. I used VC6 and the CMake settings BUILD_SINGLE_SHARED_LIBRARY. CMake then automatically diabels BUILD_APPS and enables BUILD_SHARED_APPS. When compiling, alle the obj files are created. But I cannot find any DLL created. The output of the compilation process is:

-- Install configuration: "Debug"
CMake Error at cmake_install.cmake:44 (FILE):
file INSTALL cannot find
"D:/Develop/dcmtk/dcmtk-8f6a406/Bin/bin/Debug/dcmtk.dll".
Das Sprungziel - VCReportError wurde nicht gefunden.
Fehler beim Ausführen von c:\windows\system32\cmd.exe.

Which settings I should use in CMake to really create a single DLL?
Furthrmore, why it isnt possible to check BUILD_SINGLE_SHARED_LIBRARY and BUILD_APPS together?

Uli Schlachter
DCMTK Developer
Posts: 120
Joined: Thu, 2009-11-26, 08:15

Re: single dcmtk.dll

#2 Post by Uli Schlachter »

csmeso wrote:In the november 2012 snapshot, you stated that now it is possible to build a single dcmtk.dll. I tried this, also with the latest snapshot dcmtk-8f6a406 downloaded today, but it doesnt work. I used VC6 and the CMake settings BUILD_SINGLE_SHARED_LIBRARY. CMake then automatically diabels BUILD_APPS and enables BUILD_SHARED_APPS. When compiling, alle the obj files are created. But I cannot find any DLL created.
The DLL is supposed to be in the "bin" directory where normally the exe files are placed.
csmeso wrote:-- Install configuration: "Debug"
CMake Error at cmake_install.cmake:44 (FILE):
file INSTALL cannot find
"D:/Develop/dcmtk/dcmtk-8f6a406/Bin/bin/Debug/dcmtk.dll".
Das Sprungziel - VCReportError wurde nicht gefunden.
Fehler beim Ausführen von c:\windows\system32\cmd.exe.
I guess that this is the output from running the INSTALL target? I guess that I never tested this one...
However, the output suggests that dcmtk.dll was not build. Do you get any error messages from the dcmtk target?
csmeso wrote:Furthrmore, why it isnt possible to check BUILD_SINGLE_SHARED_LIBRARY and BUILD_APPS together?
I bet the reason is mostly my own incompetence.

When you tell the build system to produce a single library, it turns all of DCMTK's library into object libraries ("ADD_LIBRARY(dcmdata OBJECT ...)") so that it can later add a new library target called "dcmtk" which links all of these object libraries together. However, we now have some "semi-cyclic" dependencies: The dcmtk target has to be added after all of the individual object libraries are known to CMake. And the apps have to be added after the "dcmtk" library was created. At the time when the CMakeLists.txt in e.g. dcmdata/ is executed, the "dcmtk" library was not added yet, so apps cannot link against it.

I hope this explanation made at least some sense.

Uli

csmeso
Posts: 17
Joined: Mon, 2006-06-19, 15:21

Re: single dcmtk.dll

#3 Post by csmeso »

I guess that this is the output from running the INSTALL target? I guess that I never tested this one...
However, the output suggests that dcmtk.dll was not build. Do you get any error messages from the dcmtk target?
No, I get no error from the INSTALL target. The message is the same when building using the BUILD_ALL target.

Howewer, when building using VC10, I get some linker errors:

2>Link:
2> Bibliothek "D:/Develop/dcmtk/dcmtk-8f6a406/Bin/lib/Release/dcmtk.lib" und Objekt "D:/Develop/dcmtk/dcmtk-8f6a406/Bin/lib/Release/dcmtk.exp" werden erstellt.
2>scpthrd.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""private: __thiscall DcmSCP::DcmSCP(class DcmSCP const &)" (??0DcmSCP@@AAE@ABV0@@Z)" in Funktion ""public: __thiscall DcmThreadSCP::DcmThreadSCP(class DcmThreadSCP const &)" (??0DcmThreadSCP@@QAE@ABV0@@Z)".
2>scppool.obj : error LNK2001: Nicht aufgelöstes externes Symbol ""private: __thiscall DcmSCP::DcmSCP(class DcmSCP const &)" (??0DcmSCP@@AAE@ABV0@@Z)".
2>scpthrd.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""private: class DcmSCP & __thiscall DcmSCP::operator=(class DcmSCP const &)" (??4DcmSCP@@AAEAAV0@ABV0@@Z)" in Funktion ""public: class DcmThreadSCP & __thiscall DcmThreadSCP::operator=(class DcmThreadSCP const &)" (??4DcmThreadSCP@@QAEAAV0@ABV0@@Z)".
2>scppool.obj : error LNK2001: Nicht aufgelöstes externes Symbol ""private: class DcmSCP & __thiscall DcmSCP::operator=(class DcmSCP const &)" (??4DcmSCP@@AAEAAV0@ABV0@@Z)".
2>D:\Develop\dcmtk\dcmtk-8f6a406\Bin\bin\Release\dcmtk.dll : fatal error LNK1120: 2 nicht aufgelöste externe Verweise.

Uli Schlachter
DCMTK Developer
Posts: 120
Joined: Thu, 2009-11-26, 08:15

Re: single dcmtk.dll

#4 Post by Uli Schlachter »

Oh hey, you are hitting that error in the new code, too.

The problem is that DcmSCP has a private undefined copy constructor and assignment operator. However, DcmThreadSCP which inherits from DcmSCP uses the default copy construct and assignment operator and thus tries to call these private undefined functions. The linker notices this and complains.

The fix for that one is simple (and is already committed to git, but is not yet available in the public git, sorry):

Code: Select all

diff --git a/dcmnet/include/dcmtk/dcmnet/scpthrd.h b/dcmnet/include/dcmtk/dcmnet/scpthrd.h
index 3a5dca3..7782816 100644
--- a/dcmnet/include/dcmtk/dcmnet/scpthrd.h
+++ b/dcmnet/include/dcmtk/dcmnet/scpthrd.h
@@ -70,6 +70,19 @@ public:
    */
   virtual OFCondition setSharedConfig(const DcmSharedSCPConfig& config);
 
+private:
+
+  /** Private undefined copy constructor. Shall never be called.
+   *  @param src Source object
+   */
+  DcmThreadSCP(const DcmThreadSCP &src);
+
+  /** Private undefined assignment operator. Shall never be called.
+   *  @param src Source object
+   *  @return Reference to this
+   */
+  DcmThreadSCP &operator=(const DcmThreadSCP &src);
+
 };
 
 #endif // SCPTHRD_H

csmeso
Posts: 17
Joined: Mon, 2006-06-19, 15:21

Re: single dcmtk.dll

#5 Post by csmeso »

Thank you for fixing the issue regarding the private constructor.
Nevertheless, I cannot compile as single DLL in VC6 (in VC 10 it works). The compiler gives no error, but no DLL is created.
If this works on your side, please tell me the CMake settings which should work. (I need DCMTK_WITH_THREADS and DCMTK_WITH_PRIVATE_TAGS)

Here is the output of the ALL_BUILD Release compile:

Code: Select all

--------------------Konfiguration: dcmtk - Win32 Release--------------------
Building Custom Rule D:/Develop/dcmtk/dcmtk-595668f/CMakeLists.txt
-- Info: DCMTK's builtin private dictionary support will be enabled
-- Info: Thread support will be enabled
-- Info: Wide char file I/O functions will be enabled
-- Info: Wide char main function for command line tools will be enabled
-- Configuring done
-- Generating done
-- Build files have been written to: D:/Develop/dcmtk/dcmtk-595668f/VC6_DLL
--------------------Konfiguration: ALL_BUILD - Win32 Release--------------------

ALL_BUILD - 0 Fehler, 103 Warnung(en)
If I perform an INSTALL build, I get:

Code: Select all

-------------------Konfiguration: INSTALL - Win32 Release--------------------
Benutzerdefinierte Build-Stufe wird für D:\Develop\dcmtk\dcmtk-595668f\VC6_DLL\INSTALL_force_1.rule ausgeführt
-- Install configuration: "Release"
CMake Error at cmake_install.cmake:46 (FILE):
  file INSTALL cannot find
  "D:/Develop/dcmtk/dcmtk-595668f/VC6_DLL/bin/Release/dcmtk.dll".
Das Sprungziel - VCReportError wurde nicht gefunden.
Fehler beim Ausführen von c:\windows\system32\cmd.exe.

INSTALL - 1 Fehler, 0 Warnung(en)

Uli Schlachter
DCMTK Developer
Posts: 120
Joined: Thu, 2009-11-26, 08:15

Re: single dcmtk.dll

#6 Post by Uli Schlachter »

You ALL_BUILD output is a little short. Did you compile anything at all? Can you compile individual targets like e.g. dcmdata_obj? Can you compile the toolkit without DLL support? If not, I guess that you need the answer to FAQ #22.

Here is what I do to compile DCMTK as a single DLL with MSVC6:
  • Get the latest source code from git
  • Run 'config/changext cxx' to rename files to a cxx file extension
  • The above was done on Linux, now I start a virtual machine with Windows XP
  • Start CMake 2.8.10.2, use some samba path for the above created source directory
  • Pick a random folder on the desktop as the build directory
  • Press 'Configure', let CMake create the build directory, select MSVC6 from the list, use default compiler, wait forever for this slow thing to finish
  • After enjoying a nice cup of coffee, it is time to enable DCMTK_WITH_THREADS (already enabled), DCMTK_WITH_PRIVATE_TAGS, BUILD_SHARED_LIBS and BUILD_SINGLE_SHARED_LIBRARY
  • Now I press 'Configure' again (CMake checks for GXX_SUPPORTS_VISIBILITY, the test fails)
  • Time to close CMake and start MSVC6 and then 'Generate'
  • Build -> Set active configuration -> ALL_BULD - Win32 Release (because you said so)
  • Press F7 and wait for half a day
Edit: The compiler just finished. And of course it didn't generate a dcmtk.dll. Neither does it do this for a debug build. Evil MSVC6! I am sure that this used to work...
Edit2: After ripping out some hair, I noticed that MSVC6 doesn't even call the linker. I added a new .cpp file to the "dcmtk" project and this convinced MSVC6 to do something. However, now linking fails because something screws up the paths to the object files. I guess that this is hitting a limit on the number and length of arguments that the MSVC6 can feed to the linker.
Edit3: Removing entries from the DCMTK_MODULES CMake variable helps! Eventually, the list of object files becomes short enough so that MSVC6 stops breaking things (I just tested with "config;ofstd;oflog;dcmdata"). Hopefully, you aren't using all of DCMTK's modules and this helps you, too.

csmeso
Posts: 17
Joined: Mon, 2006-06-19, 15:21

Re: single dcmtk.dll

#7 Post by csmeso »

Unfortunately, this doesn't solve the problem, because I need
DCMTK_MODULES = config;ofstd;oflog;dcmdata;dcmimgle;dcmimage;dcmjpeg;dcmjpls;dcmnet;dcmsr;dcmwlm
This list seems to be too long.

Uli Schlachter
DCMTK Developer
Posts: 120
Joined: Thu, 2009-11-26, 08:15

Re: single dcmtk.dll

#8 Post by Uli Schlachter »

I added an entry to our internal issue tracker (bug #509).

However, I have to say that I don't have much hope for this. My only idea would be to come up with a simple, self-contained test case and submit that as a bug report to the CMake developers and then get told by them that MSC6 is too ancient...

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest