GoogleCloudPlatform / wsi-to-dicom-converter

Conversion tool/library for converting whole slide images to DICOM
Apache License 2.0
77 stars 26 forks source link

Compiling fails on MacOS with failure to find jpeg_mem_dest, was failing finding openjpeg 2.3.1 #28

Open dclunie opened 5 years ago

dclunie commented 5 years ago

[ 96%] Building CXX object CMakeFiles/wsi2dcm.dir/src/jpeg2000Compression.cpp.o /Users/dclunie/Work/wsi2dcm/wsi-to-dicom-converter-1.0/src/jpeg2000Compression.cpp:80:3: error: no matching function for call to 'opj_stream_set_write_function' opj_stream_set_write_function( ^~~~~~~~~ /opt/local/include/openjpeg-2.3/openjpeg.h:1169:27: note: candidate function not viable: no known conversion from '(lambda at /Users/dclunie/Work/wsi2dcm/wsi-to-dicom-converter-1.0/src/jpeg2000Compression.cpp:81:12)' to 'opj_stream_write_fn' (aka 'unsigned long ()(void , unsigned long, void )') for 2nd argument OPJ_API void OPJ_CALLCONV opj_stream_set_write_function(opj_stream_t p_stream, ^ 1 error generated. make[2]: *** [CMakeFiles/wsi2dcm.dir/src/jpeg2000Compression.cpp.o] Error 1

This is with openjpeg 2.3.1 installed through macports.

David

pavertomato commented 5 years ago

hi David, seems like compiler not able to match lambda because of size_t type size, it happens with 32-bit systems or outdated compilers could you please provide more information about your environment so i could try to reproduce?

as part of investigation could you please try this patch? 0001-sizet.patch.txt

dclunie commented 5 years ago

% uname -a Darwin graythin-4.local 17.7.0 Darwin Kernel Version 17.7.0: Sun Jun 2 20:31:42 PDT 2019; root:xnu-4570.71.46~1/RELEASE_X86_64 x86_64

% g++ --version Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Apple LLVM version 10.0.0 (clang-1000.11.45.5) Target: x86_64-apple-darwin17.7.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

I applied the patch but got a different error:

[ 2%] Building CXX object CMakeFiles/wsi2dcm.dir/src/jpegCompression.cpp.o /Users/dclunie/Work/wsi2dcm/wsi-to-dicom-converter-1.0/src/jpegCompression.cpp:44:3: error: use of undeclared identifier 'jpeg_mem_dest' jpeg_mem_dest(&_cinfo, &imgd, &outlen); ^

pavertomato commented 5 years ago

thanks, i'll get back to you as soon as i reproduce this and create a fix

pavertomato commented 5 years ago

thanks, i'll get back to you as soon as i reproduce this and create a fix

i've tried to reproduce as close as possible, unfortunately i have only virtual mac could you please try this branch? https://github.com/pavertomato/wsi-to-dicom-converter-1/tree/bugfix/macBuild seems like it have all fixes

possible errors

dzelemba commented 5 years ago

Closing this now due to inactivity. Feel free to re-open if you're still experiencing issues.

dclunie commented 3 years ago

Tried this again with the latest release (cec14a1 on Jan 29), and again got show stopping jpeg_mem_dest compile error:

[ 1%] Building CXX object CMakeFiles/wsi2dcm.dir/src/jpegCompression.cpp.o /Users/dclunie/Work/wsi2dcm/wsi-to-dicom-converter-develop/src/jpegCompression.cpp:44:3: error: use of undeclared identifier 'jpeg_mem_dest' jpeg_mem_dest(&_cinfo, &imgd, &outlen); ^ /Users/dclunie/Work/wsi2dcm/wsi-to-dicom-converter-develop/src/jpegCompression.cpp:55:64: warning: inequality comparison result unused [-Wunused-comparison] jpeg_write_scanlines(&_cinfo, (JSAMPARRAY)&row_address, 1) != 1;


1 warning and 1 error generated.

This may be something to do with the way Cmake finds the JPEG libraries, the known API incompatibilities between different versions of the libjpeg API, and that I use MacPorts rather than Homebrew for package management.

Is there a way to provide a local copy of the 'correct' libjpeg and tell cmake to compile/use that instead of relying on the system configuration?

FYI ...

% grep -i jp CMakeCache.txt
JPEG_INCLUDE_DIR:PATH=/Library/Frameworks/UnixImageIO.framework/Headers
JPEG_LIBRARY_DEBUG:FILEPATH=JPEG_LIBRARY_DEBUG-NOTFOUND
JPEG_LIBRARY_RELEASE:FILEPATH=/opt/local/lib/libjpeg.dylib
//The directory containing a CMake configuration file for OpenJPEG.
OpenJPEG_DIR:PATH=/opt/local/lib/openjpeg-2.3
wsi2dcm_LIB_DEPENDS:STATIC=general;openjp2;general;/opt/local/lib/libjpeg.dylib;general;/opt/local/lib/libopenslide.dylib;general;pthread;general;z;general;m;general;lzma;general;xml2;
//Details about finding JPEG
FIND_PACKAGE_MESSAGE_DETAILS_JPEG:INTERNAL=[/opt/local/lib/libjpeg.dylib][/Library/Frameworks/UnixImageIO.framework/Headers][v62()]
//ADVANCED property for variable: JPEG_INCLUDE_DIR
JPEG_INCLUDE_DIR-ADVANCED:INTERNAL=1
//ADVANCED property for variable: JPEG_LIBRARY_DEBUG
JPEG_LIBRARY_DEBUG-ADVANCED:INTERNAL=1
//ADVANCED property for variable: JPEG_LIBRARY_RELEASE
JPEG_LIBRARY_RELEASE-ADVANCED:INTERNAL=1

David

PS. There is libjpeg-turbo discussion about the incompatibilities of the jpeg-6b and jpeg-8 APIs and as I understand it jpeg_mem_dest was introduced in the latter (e.g., "https://sourceforge.net/p/libjpeg-turbo/mailman/message/30357233/") even though I don't have libjpeg-turbo installed.
pavertomato commented 3 years ago

could you please try homebrew with https://github.com/GoogleCloudPlatform/wsi-to-dicom-converter/releases/download/v1.0.3/wsi2dcm.rb https://github.com/GoogleCloudPlatform/wsi-to-dicom-converter/tree/v1.0.3#macos ? seems like it downloads and compiles correct version, at least at my virtual mac

if it's not an option i may suggest to try https://github.com/GoogleCloudPlatform/wsi-to-dicom-converter/blob/v1.0.3/cloud_build/ubuntuBuild.sh#L40 https://www.ijg.org/files/jpegsr9c.zip but i haven't tried to compile it with mac compilers

please post updates here and i'll try to reproduce&fix issues if possible

dclunie commented 3 years ago

I can't use Homebrew because it conflicts with MacPorts.

So I tried the static build approach that you pointed to, and provided it with jpegsrc9c as well as the other packages listed in the instructions and in that script.

But now openslide fails to configure when I do "cmake -DSTATIC_BUILD=ON ..":

configure: error: in `/Users/dclunie/Work/wsi2dcm/wsi-to-dicom-converter-develop/build/openslide-3.4.1': configure: error: cannot find libjpeg

pavertomato commented 3 years ago

So I tried the static build approach that you pointed to, and provided it with jpegsrc9c as well as the other packages listed in the instructions and in that script.

oh, seems like static build on mac is not what simple, i meant you may try to compile and install https://www.ijg.org/files/jpegsr9c.zip(make && make install) as i remember it should act as same as in linux correct version headers and bins of libjpeg should be added into common paths, and after it try usual approach with dynamic build