Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dcm2niix as static lib (now failing) ? #722

Closed
buildqa opened this issue Jun 22, 2023 · 1 comment
Closed

dcm2niix as static lib (now failing) ? #722

buildqa opened this issue Jun 22, 2023 · 1 comment

Comments

@buildqa
Copy link

buildqa commented Jun 22, 2023

Our project has built the dcm2niix source as a static library and then linked against it when building binary applications for both linux and MacOS. For the Mac, Intel binaries have been built on Mac OS 10.15 with the clang 12 compilers. But after switching to the v1.0.20230411 dcm2niix release, while building and linking against a libdcm2niix.a still works, now applications on macOS fail with a run time error, e.g., when readDICOM or readDICOMx are called,

This does not read to me like the symbol _chkstk_darwin is missing. The makefile listed here, https://github.com/rordenlab/dcm2niix/blob/master/console/makefile, lists what LDFLAGS should be for building a dcm2niix application with gcc (and not clang). But it is not clear to me what CFLAGS and/or LDFLAGS apply in our case of using clang12 to create libdcm2niix.a . Happy to hear any advice you may care to offer.

@neurolabusc
Copy link
Collaborator

dcm2niix is primarily developed on a M2 Mac using Clang 14, using the -arch arm64 and -arch x86_64 arguments to cross-compile to both architectures (and then using lipo to create a binary that works on both architectures. So a minimal compile might look like this:

g++ -O3 -arch arm64 -sectcreate __TEXT __info_plist Info.plist -I. -DmyEnableJNIFTI base64.cpp cJSON.cpp  -Wl,-stack_size -Wl,0x1000000 main_console.cpp nii_foreign.cpp nii_dicom.cpp jpg_0XC3.cpp ujpeg.cpp nifti1_io_core.cpp nii_ortho.cpp nii_dicom_batch.cpp -o dcm2niixARM -DmyDisableOpenJPEG
g++ -O3 -arch x86_64 -sectcreate __TEXT __info_plist Info.plist -I. -DmyEnableJNIFTI base64.cpp cJSON.cpp  -Wl,-stack_size -Wl,0x1000000 main_console.cpp nii_foreign.cpp nii_dicom.cpp jpg_0XC3.cpp ujpeg.cpp nifti1_io_core.cpp nii_ortho.cpp nii_dicom_batch.cpp -o dcm2niixX86 -DmyDisableOpenJPEG
lipo -create -output dcm2niix ./dcm2niixARM ./dcm2niixX86 

For any release, you can see the minimal make command for your operating system with:

git clone git@github.com:rordenlab/dcm2niix.git
cd dcm2niix/console
make

which for the current stable release on MacOS will create a build for the native architecture:

g++ -O3 -sectcreate __TEXT __info_plist Info.plist -I. -DmyEnableJNIfTI base64.cpp cJSON.cpp  -Wl,-stack_size -Wl,0x1000000 main_console.cpp nii_foreign.cpp nii_dicom.cpp jpg_0XC3.cpp ujpeg.cpp nifti1_io_core.cpp nii_ortho.cpp nii_dicom_batch.cpp -o dcm2niix -DmyDisableOpenJPEG

Note that these minimal installs will not support the (rare) JPEG2000 (using the OpenJPEG library) and JPEG-LS (using the charls library) transfer syntaxes. The cmake files provide recipes for supporting these. The cmake capabilities have evolved a lot since 2014 PR you link to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants