Self built OpenSSL version 3.0.8 names

Compilation and installation of DCMTK

Moderator: Moderator Team

Message
Author
thomb
Posts: 89
Joined: Mon, 2024-05-20, 08:10

Re: Self built OpenSSL version 3.0.8 names

#16 Post by thomb »

Turns out the library names matter (thought it only mattered when they were downloaded from DCMTK website).
I also found out that if the CMake process doesn't find the libraries with those names, it will not find the functions it needs to find to setup OpenSSL/DCMTK for building.
I didn't realize that the process looked into the libraries. I thought they only looked into the ts.h header file.

thomb
Posts: 89
Joined: Mon, 2024-05-20, 08:10

Re: Self built OpenSSL version 3.0.8 names

#17 Post by thomb »

Looks like changing the .lib names helps with the configure/generate steps and allows the build to work later.
However, the tool exes are still looking for DLLs named: libssl-3-x64.dll and libcrypto-3-x64.dll.

I have asked the OpenSSL team if there is a way to set the names during their build process.

Since the DCMTK team has built several versions of OpenSSL, perhaps they have advice too.

Marco Eichelberg
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 1497
Joined: Tue, 2004-11-02, 17:22
Location: Oldenburg, Germany
Contact:

Re: Self built OpenSSL version 3.0.8 names

#18 Post by Marco Eichelberg »

We use a CMake script that modifies the makefile after OpenSSL's Perl configure script has generated it. Here are the relevant parts:

Code: Select all

file(READ "makefile" MAKEFILE)
if(DEBUG)
    string(REGEX REPLACE "lib(crypto|ssl)([^ \n\t\r]*\\.)(dll|lib|def|pdb)" "dcmtk\\1_d\\2\\3" MAKEFILE "${MAKEFILE}")
    string(REGEX REPLACE "LIBRARY lib(crypto|ssl)" "LIBRARY dcmtk\\1_d" MAKEFILE "${MAKEFILE}")
else()
    string(REGEX REPLACE "lib(crypto|ssl)([^ \n\t\r]*\\.)(lib|def)" "dcmtk\\1_o\\2\\3" MAKEFILE "${MAKEFILE}")
    string(REGEX REPLACE "lib(crypto|ssl)([^ \n\t\r]*\\.)(dll|pdb)" "dcmtk\\1\\2\\3" MAKEFILE "${MAKEFILE}")
    string(REGEX REPLACE "LIBRARY lib(crypto|ssl)" "LIBRARY dcmtk\\1" MAKEFILE "${MAKEFILE}")
endif()
if(MT)
    string(REGEX REPLACE "(\nCFLAGS=[^\n]*)/MD([^\n]*\n)" "\\1/MT\\2" MAKEFILE "${MAKEFILE}")
    string(REGEX REPLACE "(\nBIN_CFLAGS=[^\n]*)/MD([^\n]*\n)" "\\1/MT\\2" MAKEFILE "${MAKEFILE}")
endif()
# What a great idea to write a .def file that overwrites the library name
# passed to the linker as an argument with a fixed and non-configurable
# string.
# Now to fix this genius idea, let's employ some regex magic that patches some
# regex magic into the Makefile...
string(REGEX REPLACE
    "(\t[^\r\n]*util[\\]mkdef[.]pl[^>]*)(> [$]@)"
    "\\1| sed \"/^LIBRARY/d\" \\2"
    MAKEFILE "${MAKEFILE}"
)
file(WRITE "makefile" "${MAKEFILE}")

Michael Onken
DCMTK Developer
Posts: 2072
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

Re: Self built OpenSSL version 3.0.8 names

#19 Post by Michael Onken »

Hi,

I tried to use pre-built current version of OpenSSL to check building DCMTK with it. This is what I have done:
  1. Download Windows build of OpenSSL. I used this one (Win64 OpenSSL v3.3.1 MSI installer): https://slproweb.com/products/Win32OpenSSL.html
  2. Configure DCMTK in CMake (no options set)
  3. When configured with default options, enable the following option: DCMTK_USE_FIND_PACKAGE (should be pre-defined but disabled)
  4. Also, enable the following option: DCMTK_WITH_OPENSSL
  5. Configure in CMake again to take over these settings
  6. Generate project files in CMake
  7. Compile DCMTK in Visual Studio (e.g. build storescu which is an SSL-enabled tool if you don't want a full build for testing)
  8. Run storescu --version to see whether it prints the OpenSSL version you wanted to link agianst.
  9. Note that running the executables will require the OpenSSL DLLS to be in your DLL path, e.g. copy to the directory where the executable is stored.
This works for me using current DCMTK code and OpenSSL 3.3.1.

BR Michael

Michael Onken
DCMTK Developer
Posts: 2072
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

Re: Self built OpenSSL version 3.0.8 names

#20 Post by Michael Onken »

P.S: I also tried with a self-built OpenSSL. It also works for my out of the box.
  1. Download Windows build of OpenSSL. I used this one (Win64 OpenSSL v3.3.1 MSI installer Download and build source code as described here: https://wiki.openssl.org/index.php/Comp ... lation#W64
  2. Configure DCMTK in CMake (no options set)
  3. When configured with default options, enable the following option: DCMTK_USE_FIND_PACKAGE (should be pre-defined but disabled)
  4. Also, enable the following option: DCMTK_WITH_OPENSSL
  5. Also, add the following CMake Option: OPENSSL_ROOT_DIR and set it to your downloaded (and built) version of OpenSSL directory (for me it was C:/Users/onken/Downloads/openssl-3.3.1)
  6. ...rest as above

thomb
Posts: 89
Joined: Mon, 2024-05-20, 08:10

Re: Self built OpenSSL version 3.0.8 names

#21 Post by thomb »

Michael Onken wrote: Mon, 2024-07-29, 09:31 Hi,

I tried to use pre-built current version of OpenSSL to check building DCMTK with it. This is what I have done:
  1. Download Windows build of OpenSSL. I used this one (Win64 OpenSSL v3.3.1 MSI installer): https://slproweb.com/products/Win32OpenSSL.html
  2. Configure DCMTK in CMake (no options set)
  3. When configured with default options, enable the following option: DCMTK_USE_FIND_PACKAGE (should be pre-defined but disabled)
  4. Also, enable the following option: DCMTK_WITH_OPENSSL
  5. Configure in CMake again to take over these settings
  6. Generate project files in CMake
  7. Compile DCMTK in Visual Studio (e.g. build storescu which is an SSL-enabled tool if you don't want a full build for testing)
  8. Run storescu --version to see whether it prints the OpenSSL version you wanted to link agianst.
  9. Note that running the executables will require the OpenSSL DLLS to be in your DLL path, e.g. copy to the directory where the executable is stored.
This works for me using current DCMTK code and OpenSSL 3.3.1.

BR Michael
Thank you Michael.

I was running CMake Configure with DCMTK_USE_FIND_PACKAGE disabled (DCMTK_USE_FIND_PACKAGE:BOOL=OFF in CMakeCache.txt). So it seems I should have enabled this and it would have find my actual libraries?
DCMTK_WITH_OPENSSL was enabled (DCMTK_WITH_OPENSSL:BOOL=ON)

What confused me is CMake seemed to find the include and lib paths just fine. The only thing it didn't get right were the library names
WITH_OPENSSLINC:PATH=C:/repos/mmi-director-dcmtk-3.6.8/openssl-3.0.8-win32
DCMTK_LIBRARY_DEPENDENCIES:INTERNAL=config;iphlpapi;ws2_32;netapi32;wsock32;iphlpapi;ws2_32;netapi32;wsock32;crypt32;debug;C:/repos/mmi-director-dcmtk-3.6.8/openssl-3.0.8-win32/lib/dcmtkssl_d.lib;optimized;C:/repos/mmi-director-dcmtk-3.6.8/openssl-3.0.8-win32/lib/dcmtkssl_o.lib;debug;C:/repos/mmi-director-dcmtk-3.6.8/openssl-3.0.8-win32/lib/dcmtkcrypto_d.lib;optimized;C:/repos/mmi-director-dcmtk-3.6.8/openssl-3.0.8-win32/lib/dcmtkcrypto_o.lib;crypt32;debug;C:/repos/mmi-director-dcmtk-3.6.8/openssl-3.0.8-win32/lib/dcmtkssl_d.lib;optimized;C:/repos/mmi-director-dcmtk-3.6.8/openssl-3.0.8-win32/lib/dcmtkssl_o.lib;debug;C:/repos/mmi-director-dcmtk-3.6.8/openssl-3.0.8-win32/lib/dcmtkcrypto_d.lib;optimized;C:/repos/mmi-director-dcmtk-3.6.8/openssl-3.0.8-win32/lib/dcmtkcrypto_o.lib

thomb
Posts: 89
Joined: Mon, 2024-05-20, 08:10

Re: Self built OpenSSL version 3.0.8 names

#22 Post by thomb »

Michael Onken wrote: Mon, 2024-07-29, 10:21 P.S: I also tried with a self-built OpenSSL. It also works for my out of the box.
  1. Download Windows build of OpenSSL. I used this one (Win64 OpenSSL v3.3.1 MSI installer Download and build source code as described here: https://wiki.openssl.org/index.php/Comp ... lation#W64
  2. Configure DCMTK in CMake (no options set)
  3. When configured with default options, enable the following option: DCMTK_USE_FIND_PACKAGE (should be pre-defined but disabled)
  4. Also, enable the following option: DCMTK_WITH_OPENSSL
  5. Also, add the following CMake Option: OPENSSL_ROOT_DIR and set it to your downloaded (and built) version of OpenSSL directory (for me it was C:/Users/onken/Downloads/openssl-3.3.1)
  6. ...rest as above
I considered using this method but never tried it because I thought OPENSSL_ROOT_DIR was only for downloaded already built openssl packages.

For both of your suggested options, did I misunderstand the instructions in INSTALL? I thought I followed the instructions for creating my own libraries and putting them in a place that CMake configure would find them.
With the variations I tried, perhaps I lost track of the part about using DCMTK_USE_FIND_PACKAGE.
I had been relying on the default search behavior finding my includes and libs. As this text from INSTALL suggested and most of the behavior had me think was happening.
- OPENSSL_ROOT_DIR: Directory where OpenSSL is installed.
Default: search in standard directories for headers and libraries.
I didn't see DCMTK_USE_FIND_PACKAGE mentioned in the INSTALL file.

Thank you for your help.

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests