ruven / iipsrv

iipsrv is an advanced high-performance feature-rich image server for web-based streamed viewing and zooming of ultra high-resolution images.
https://iipimage.sourceforge.io
GNU General Public License v3.0
292 stars 115 forks source link

please add support to compile on macOS with ARM architecture / homebrew #275

Open sbarex opened 4 days ago

sbarex commented 4 days ago

Hi, Please add support for compiling on macOS with ARM architecture and external libraries installed via homebrew. On Apple Silicon homebrew installs applications and libraries not to /usr/local/ but inside /opt/homebrew/.

I'm on a Apple Silicon, macOS 15.1.1. Libtiff, libjpeg, openjpeg installed via homebrew. I downloaded the IIPSRV repository via git and ran autogen.sh:

Preparing the iipsrv build system...please wait

Found GNU Autoconf version 2.72
Found GNU Automake version 1.17
Found GNU Libtool version 2.5.4

Automatically preparing build ... done

The iipsrv build system is now prepared.  To build here, run:
  ./configure
  make

Then, executing ./configure the libtiff headers are not found:

Configuring iipsrv ...

checking for a BSD-compatible install... /opt/homebrew/bin/ginstall -c
checking whether sleep supports fractional seconds... yes
checking filesystem timestamp resolution... 2
checking whether build environment is sane... yes
checking for a race-free mkdir -p... /opt/homebrew/bin/gmkdir -p
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking xargs -n works... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether gcc accepts -g... yes
checking for gcc option to enable C11 features... none needed
checking whether gcc understands -c and -o together... yes
checking whether make supports the include directive... yes (GNU style)
checking dependency style of gcc... gcc3
checking for g++... g++
checking whether the compiler supports GNU C++... yes
checking whether g++ accepts -g... yes
checking for g++ option to enable C++11 features... -std=gnu++11
checking dependency style of g++ -std=gnu++11... gcc3
checking whether ln -s works... yes
checking whether make sets $(MAKE)... (cached) yes
checking for inline... inline
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for size_t... yes
checking for uint8_t... yes
checking for uint32_t... yes
checking build system type... aarch64-apple-darwin24.1.0
checking host system type... aarch64-apple-darwin24.1.0
checking how to print strings... printf
checking for a sed that does not truncate output... /opt/homebrew/bin/gsed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /Library/Developer/CommandLineTools/usr/bin/ld
checking if the linker (/Library/Developer/CommandLineTools/usr/bin/ld) is GNU ld... no
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking the maximum length of command line arguments... 786432
checking how to convert aarch64-apple-darwin24.1.0 file names to aarch64-apple-darwin24.1.0 format... func_convert_file_noop
checking how to convert aarch64-apple-darwin24.1.0 file names to toolchain format... func_convert_file_noop
checking for /Library/Developer/CommandLineTools/usr/bin/ld option to reload object files... -r
checking for file... file
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ranlib... ranlib
checking for ar... ar
checking for archiver @FILE support... no
checking for strip... strip
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for mt... no
checking if : is a manifest tool... no
checking for dsymutil... dsymutil
checking for nmedit... nmedit
checking for lipo... lipo
checking for otool... otool
checking for otool64... no
checking for -single_module linker flag... ld: warning: -single_module is obsolete
no
checking for -no_fixup_chains linker flag... yes
checking for -exported_symbols_list linker flag... yes
checking for -force_load linker flag... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... yes
checking for gcc option to produce PIC... -fno-common -DPIC
checking if gcc PIC flag -fno-common -DPIC works... yes
checking if gcc static flag -static works... no
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/Library/Developer/CommandLineTools/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin24.1.0 dyld
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking how to run the C++ preprocessor... g++ -std=gnu++11 -E
checking for ld used by g++ -std=gnu++11... /Library/Developer/CommandLineTools/usr/bin/ld
checking if the linker (/Library/Developer/CommandLineTools/usr/bin/ld) is GNU ld... no
checking whether the g++ -std=gnu++11 linker (/Library/Developer/CommandLineTools/usr/bin/ld) supports shared libraries... yes
checking for g++ -std=gnu++11 option to produce PIC... -fno-common -DPIC
checking if g++ -std=gnu++11 PIC flag -fno-common -DPIC works... yes
checking if g++ -std=gnu++11 static flag -static works... no
checking if g++ -std=gnu++11 supports -c -o file.o... yes
checking if g++ -std=gnu++11 supports -c -o file.o... (cached) yes
checking whether the g++ -std=gnu++11 linker (/Library/Developer/CommandLineTools/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin24.1.0 dyld
checking how to hardcode library paths into programs... immediate
checking for sys/stat.h... (cached) yes
checking for time.h... yes
checking for sys/time.h... yes
checking for syslog.h... yes
checking for library containing pow... none required
checking for log2 in -lm... yes
checking for setenv... yes
checking for GNU libc compatible malloc... yes
checking for glob.h... yes
checking for windows.h... no
checking for gcc option to enable large file support... none needed
checking for isfinite... yes
checking how to run the C preprocessor... gcc -E
checking for egrep -e... (cached) /usr/bin/grep -E
checking whether gcc is Clang... yes
checking whether pthreads work with "-pthread" and "-lpthread"... yes
checking whether Clang needs flag to prevent "argument unused" warning when linking with -pthread... no
checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE
checking whether more special flags are required for pthreads... no
checking for PTHREAD_PRIO_INHERIT... yes
checking for gcc option to support OpenMP... unsupported
checking for ext/pool_allocator.h... no
checking for chrono... yes
checking for unordered_map... yes
checking for tr1/unordered_map... no
checking for ext/hash_map... yes
checking for thread... yes
checking whether g++ -std=gnu++11 supports C++11 features by default... yes
checking for tiffio.h... no
configure: error: No libtiff headers found

To be able to compile I have to manually add via CFLAGS, CXXFLAGS and LDFLAGS the correct path to the libraries installed with homebrew:

CFLAGS=-I/opt/homebrew/include CXXFLAGS=-I/opt/homebrew/include LDFLAGS=-L/opt/homebrew/lib ./configure
Configuring iipsrv ...

checking for a BSD-compatible install... /opt/homebrew/bin/ginstall -c
checking whether sleep supports fractional seconds... yes
checking filesystem timestamp resolution... 2
checking whether build environment is sane... yes
checking for a race-free mkdir -p... /opt/homebrew/bin/gmkdir -p
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking xargs -n works... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether gcc accepts -g... yes
checking for gcc option to enable C11 features... none needed
checking whether gcc understands -c and -o together... yes
checking whether make supports the include directive... yes (GNU style)
checking dependency style of gcc... gcc3
checking for g++... g++
checking whether the compiler supports GNU C++... yes
checking whether g++ accepts -g... yes
checking for g++ option to enable C++11 features... -std=gnu++11
checking dependency style of g++ -std=gnu++11... gcc3
checking whether ln -s works... yes
checking whether make sets $(MAKE)... (cached) yes
checking for inline... inline
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for size_t... yes
checking for uint8_t... yes
checking for uint32_t... yes
checking build system type... aarch64-apple-darwin24.1.0
checking host system type... aarch64-apple-darwin24.1.0
checking how to print strings... printf
checking for a sed that does not truncate output... /opt/homebrew/bin/gsed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /Library/Developer/CommandLineTools/usr/bin/ld
checking if the linker (/Library/Developer/CommandLineTools/usr/bin/ld) is GNU ld... no
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking the maximum length of command line arguments... 786432
checking how to convert aarch64-apple-darwin24.1.0 file names to aarch64-apple-darwin24.1.0 format... func_convert_file_noop
checking how to convert aarch64-apple-darwin24.1.0 file names to toolchain format... func_convert_file_noop
checking for /Library/Developer/CommandLineTools/usr/bin/ld option to reload object files... -r
checking for file... file
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ranlib... ranlib
checking for ar... ar
checking for archiver @FILE support... no
checking for strip... strip
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for mt... no
checking if : is a manifest tool... no
checking for dsymutil... dsymutil
checking for nmedit... nmedit
checking for lipo... lipo
checking for otool... otool
checking for otool64... no
checking for -single_module linker flag... ld: warning: -single_module is obsolete
no
checking for -no_fixup_chains linker flag... yes
checking for -exported_symbols_list linker flag... yes
checking for -force_load linker flag... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... yes
checking for gcc option to produce PIC... -fno-common -DPIC
checking if gcc PIC flag -fno-common -DPIC works... yes
checking if gcc static flag -static works... no
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/Library/Developer/CommandLineTools/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin24.1.0 dyld
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking how to run the C++ preprocessor... g++ -std=gnu++11 -E
checking for ld used by g++ -std=gnu++11... /Library/Developer/CommandLineTools/usr/bin/ld
checking if the linker (/Library/Developer/CommandLineTools/usr/bin/ld) is GNU ld... no
checking whether the g++ -std=gnu++11 linker (/Library/Developer/CommandLineTools/usr/bin/ld) supports shared libraries... yes
checking for g++ -std=gnu++11 option to produce PIC... -fno-common -DPIC
checking if g++ -std=gnu++11 PIC flag -fno-common -DPIC works... yes
checking if g++ -std=gnu++11 static flag -static works... no
checking if g++ -std=gnu++11 supports -c -o file.o... yes
checking if g++ -std=gnu++11 supports -c -o file.o... (cached) yes
checking whether the g++ -std=gnu++11 linker (/Library/Developer/CommandLineTools/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin24.1.0 dyld
checking how to hardcode library paths into programs... immediate
checking for sys/stat.h... (cached) yes
checking for time.h... yes
checking for sys/time.h... yes
checking for syslog.h... yes
checking for library containing pow... none required
checking for log2 in -lm... yes
checking for setenv... yes
checking for GNU libc compatible malloc... yes
checking for glob.h... yes
checking for windows.h... no
checking for gcc option to enable large file support... none needed
checking for isfinite... yes
checking how to run the C preprocessor... gcc -E
checking for egrep -e... (cached) /usr/bin/grep -E
checking whether gcc is Clang... yes
checking whether pthreads work with "-pthread" and "-lpthread"... yes
checking whether Clang needs flag to prevent "argument unused" warning when linking with -pthread... no
checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE
checking whether more special flags are required for pthreads... no
checking for PTHREAD_PRIO_INHERIT... yes
checking for gcc option to support OpenMP... unsupported
checking for ext/pool_allocator.h... no
checking for chrono... yes
checking for unordered_map... yes
checking for tr1/unordered_map... no
checking for ext/hash_map... yes
checking for thread... yes
checking whether g++ -std=gnu++11 supports C++11 features by default... yes
checking for tiffio.h... yes
checking for TIFFOpen in -ltiff... yes
checking whether libtiff can be compiled... yes
checking whether libtiff can be linked... yes
checking for jpeglib.h... yes
checking for jpeg_abort in -ljpeg... yes
checking whether libjpeg can be compiled... yes
checking whether libjpeg can be linked... yes
checking for libmemcached/memcached.h... no
checking for png.h... yes
checking for library containing png_create_write_struct... -lpng
checking for webp/encode.h... yes
checking for library containing WebPEncode... -lwebp
checking for library containing WebPMuxAssemble... -lwebpmux
checking for avif/avif.h... yes
checking for library containing avifEncoderAddImage... -lavif
configure: optional dynamic module loading not enabled 
checking pkg-config m4 macros... yes
checking for pkg-config... /opt/homebrew/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for libopenjp2... yes
checking for fcgiapp.h... yes
checking for FCGI_Accept in -lfcgi... yes
checking whether make sets $(MAKE)... (cached) yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: creating man/Makefile
config.status: creating fcgi/Makefile
config.status: creating fcgi/include/Makefile
config.status: creating fcgi/libfcgi/Makefile
config.status: executing depfiles commands
config.status: executing libtool commands

Options Enabled:
--------------------------------
 Memcached   :  false
 JPEG2000    :  true (OpenJPEG)
 OpenMP      :  true
 Loggers     :  file, syslog
 PNG  Output :  true
 WebP Output :  true
 AVIF Output :  true
--------------------------------

Then make compiles successful.

ruven commented 3 days ago

I, in fact, submitted a formula for iipsrv 1.2 for inclusion of iipsrv within Homebrew itself (https://github.com/ruven/homebrew-core/blob/8c6db7092a78addb9016ae4d005f89dd20097e08/Formula/i/iipsrv.rb), but there were some minor issues they didn't like. I'll re-submit when I release version 1.3 - the formula will then hopefully be sufficiently clean for acceptance and you'll be able to install iipsrv directly via Homebrew.

In the meantime, yes, to compile from source you'll need to add the appropriate homebrew paths if these are not standard. In any case, it's good to know that it compiles cleanly on ARM.

sbarex commented 2 days ago

Yes, the compilation works correctly.

I don't know why the compiled file for intel is 487 kb while for (only) arm it's 1Mb. I didn't understand how to statically link all the dependencies, but it's not a big problem.

ahankinson commented 2 days ago

if you run file on the compiled binary might tell you. Something that's twice the size makes me think it might be producing a "fat" binary (intel + arm in one) but that's just a guess.

sbarex commented 2 days ago

No, there is only the arm architecture: Mach-O 64-bit executable arm64.