Steps for building dcraw_emu with USE_DNGSDK

Hello!

I'm trying to build dcraw_emu with the DNG SDK support enabled and I can't figure out how to get the DNG SDK to generate static or dynamic libs to link against. I saw the commented out lines to enable DNG SDK Support in Makefile.dist, but when I build dngvalidate, it just builds the executable and doesn't populate libs into a release folder like the makefile is expecting.

Are there any steps available for how to build the DNG SDK into a format that works with the libraw makefiles? I'm trying to build on macOS and Linux, but I'd take any help or pointers for either.

Thanks!
Nora

Forums: 

We cannot provide support for

We cannot provide support for components from other vendors. For all questions related to dng sdk please contact Adobe support.

As an exception for the rule above: to create Adobe DNG SDK library (shared or static) just create corresponding build target (static or shared library) in your build environment (MS VS, XCode, whatever...) with all Adobe DNG SDK sources excluding source/dng_validate.cpp

-- Alex Tutubalin @LibRaw LLC

I'm building the DNG SDK

I'm building the DNG SDK using cmake and this CMakeLists.txt. This creates a static library, on Windows, Linux and macos.

cmake_minimum_required(VERSION 3.15)
project(dng)
 
INCLUDE_DIRECTORIES( ${JPEG_INCLUDE_DIR} )
ADD_DEFINITIONS( ${JPEG_DEFINITIONS} )
 
INCLUDE_DIRECTORIES( ${ZLIB_INCLUDE_DIR} )
ADD_DEFINITIONS( ${ZLIB_DEFINITIONS} )
INCLUDE_DIRECTORIES( ${JXL_INCLUDE_DIR} )
ADD_DEFINITIONS( ${JXL_DEFINITIONS} )
INCLUDE_DIRECTORIES( ${XMP_INCLUDE_DIR} )
ADD_DEFINITIONS( ${XMP_DEFINITIONS} )
 
FILE(GLOB SRCFILES ${CMAKE_CURRENT_SOURCE_DIR}/dng_sdk/source/*.cpp)
FILE(GLOB HFILES ${CMAKE_CURRENT_SOURCE_DIR}/dng_sdk/source/*.h)
ADD_LIBRARY(dng-sdk STATIC ${SRCFILES})
 
TARGET_INCLUDE_DIRECTORIES( dng-sdk INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/source )
SET_TARGET_PROPERTIES(dng-sdk PROPERTIES PUBLIC_HEADER "${HFILES}")
 
set_property(TARGET dng-sdk PROPERTY CXX_STANDARD 17)
 
TARGET_COMPILE_DEFINITIONS( dng-sdk PUBLIC
                            -DqDNGThreadSafe=0
                            -DqDNG64Bit=1
                            -DqDNGDebug=0                      # do not compile debug code
                            -DqDNGValidateTarget=0             # do not build dng_validate-binary
                            -DqDNGUseLibJPEG=1                 # use libjpeg
                            -DqDNGXMPFiles=0 -DqDNGXMPDocOps=0 # build minimal XMP-set
                            -DqDNGUseStdInt=1                  # Must be set to 1, else do not compile under Linux.
)
 
# Check processor endianness (todo: not sure bigEndian platforms are set correctly)
INCLUDE(TestBigEndian)
TEST_BIG_ENDIAN(IS_BIG_ENDIAN)
IF(NOT IS_BIG_ENDIAN)
    TARGET_COMPILE_DEFINITIONS( dng-sdk PUBLIC -DqDNGLittleEndian=1)
ENDIF(NOT IS_BIG_ENDIAN)
 
IF (WIN32)
    if(MSVC)
        TARGET_COMPILE_OPTIONS( dng-sdk PRIVATE /GR /EHsc)
    else()
        TARGET_COMPILE_OPTIONS( dng-sdk PRIVATE -fexceptions)
    endif()
    TARGET_COMPILE_DEFINITIONS( dng-sdk PRIVATE -DqWinOS=1 -DqMacOS=0 -DqLinux=0 -DWIN_ENV -DWIN32 -D_WINDOWS)
ELSEIF (APPLE)
    TARGET_COMPILE_OPTIONS( dng-sdk PRIVATE -fexceptions )
    TARGET_COMPILE_DEFINITIONS( dng-sdk PRIVATE -DqWinOS=0 -DqMacOS=1 -DqLinux=0 -DMAC_ENV)
ELSE()
    TARGET_COMPILE_OPTIONS( dng-sdk PRIVATE -fexceptions -fPIE)
    TARGET_COMPILE_DEFINITIONS( dng-sdk PRIVATE -DqWinOS=0 -DqMacOS=0 -DqLinux=1 -DUNIX_ENV)
ENDIF()
 
install(TARGETS dng-sdk DESTINATION lib PUBLIC_HEADER DESTINATION include)

Oh and I'm applying this

Oh and I'm applying this patch to make it compatible with current jxl library:

--- a/dng_sdk_1_7/dng_sdk/source/dng_jxl.cpp
+++ b/dng_sdk_1_7/dng_sdk/source/dng_jxl.cpp
@@ -2283,6 +2283,7 @@ void dng_jxl_decoder::Decode (dng_host &host,
 			// result of JxlDecoderGetColorAsEncodedProfile?
 
 			JxlPixelFormat format = { 3, JXL_TYPE_FLOAT, JXL_NATIVE_ENDIAN, 0 };
+			(void)format;
 
 			#if qDNGValidate
 			if (gVerbose)
@@ -2293,7 +2294,7 @@ void dng_jxl_decoder::Decode (dng_host &host,
 
 			if (JXL_DEC_SUCCESS ==
 				JxlDecoderGetColorAsEncodedProfile (dec,
-													&format,
+													// &format,
 													JXL_COLOR_PROFILE_TARGET_ORIGINAL,
 													&color_encoding))
 				{
@@ -2442,7 +2443,7 @@ void dng_jxl_decoder::Decode (dng_host &host,
 
 				CheckResult (JxlDecoderGetICCProfileSize
 							 (dec,
-							  &format,
+							  //&format,
 							  JXL_COLOR_PROFILE_TARGET_ORIGINAL,
 							  &profile_size),
 							 "JxlDecoderGetICCProfileSize",
@@ -2469,7 +2470,7 @@ void dng_jxl_decoder::Decode (dng_host &host,
 
 				CheckResult (JxlDecoderGetColorAsICCProfile
 							 (dec,
-							  &format,
+							  // &format,
 							  JXL_COLOR_PROFILE_TARGET_ORIGINAL,
 							  profile,
 							  profile_size),
-- 

No worries Alex, thanks for

No worries Alex, thanks for the reply and thanks joostn for your CMake steps!

I had started on a process from scratch last week after seeing Alex's reply and put up a gist for the macOS side here before I saw joostn's reply: https://gist.github.com/mikamikem/4e826bb9cf5beacd86ba00e42ba0b115#file-...

Linux steps here: https://gist.github.com/mikamikem/6cf1530b2fa7b011eadd46e19ed9aab7#file-...

I'm not a huge fan of my steps (a few of the stages feel like major hacks), so I might re-approach this with your CMake file and diff when I have time in the future. Thanks again for sharing!