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

Build for Apple Silicon #696

Open
sdmaclea opened this issue Mar 5, 2021 · 5 comments
Open

Build for Apple Silicon #696

sdmaclea opened this issue Mar 5, 2021 · 5 comments

Comments

@sdmaclea
Copy link

sdmaclea commented Mar 5, 2021

dotnet/runtime#49111 notes a .NET Core dependency on libgdiplus.

I was able to get a build completed by

# Install commandline tools
xcode-select --install

# Install dependencies
brew update
brew upgrade
brew install
brew install glib cairo libexif libjpeg giflib libtiff autoconf libtool automake pango pkg-config
brew link gettext --force

Apply patch to work around autogen.sh not finding libpng16

diff --git a/configure.ac b/configure.ac
index 68f1852..c6fc211 100644
--- a/configure.ac
+++ b/configure.ac
@@ -162,7 +162,7 @@ case "$host" in
 
        *-*-darwin*)
                AC_DEFINE_UNQUOTED(OSX,1,[OS X])
-               no_libpng16=yes # workaround until we can upgrade the libpng used by bockbuild
+               # no_libpng16=yes # workaround until we can upgrade the libpng used by bockbuild
                ;;
 
        *)
PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig ./autogen.sh --prefix=YOUR_PREFIX
# Fix include path issues
ln -s /opt/homebrew/Cellar/cairo/1.16.0_5/include/cairo /opt/homebrew/Cellar/cairo/1.16.0_5/include/cairo/cairo
make

Run tests

% make check
Making check in src
make[1]: Nothing to be done for `check'.
Making check in tests
/Applications/Xcode.app/Contents/Developer/usr/bin/make  check-TESTS
PASS: testadjustablearrowcap
../test-driver: line 109: 30676 Abort trap: 6           "$@" > $log_file 2>&1
FAIL: testbitmap
PASS: testbits
PASS: testbmpcodec
PASS: testbrush
PASS: testclip
../test-driver: line 109: 30771 Abort trap: 6           "$@" > $log_file 2>&1
FAIL: testcodecs
PASS: testcustomlinecap
PASS: testemfcodec
PASS: testfont
../test-driver: line 109: 30847 Abort trap: 6           "$@" > $log_file 2>&1
FAIL: testgifcodec
PASS: testgeneral
../test-driver: line 109: 30885 Abort trap: 6           "$@" > $log_file 2>&1
FAIL: testgpimage
PASS: testgraphics
PASS: testgraphicsdraw
PASS: testgraphicsfill
PASS: testgraphicspath
PASS: testhatchbrush
PASS: testicocodec
PASS: testimageattributes
PASS: testlineargradientbrush
PASS: testmatrix
PASS: testmetafile
PASS: testpathgradientbrush
PASS: testpen
PASS: testpng
PASS: testpngcodec
PASS: testregion
PASS: testreversepath
PASS: testsolidbrush
PASS: teststringformat
PASS: testtexturebrush
PASS: testtext
PASS: testwmfcodec
============================================================================
Testsuite summary for libgdiplus 6.1
============================================================================
# TOTAL: 34
# PASS:  30
# SKIP:  0
# XFAIL: 0
# FAIL:  4
# XPASS: 0
# ERROR: 0
============================================================================
See tests/test-suite.log
Please report to https://github.com/mono/mono/issues/new
============================================================================
make[3]: *** [test-suite.log] Error 1
make[2]: *** [check-TESTS] Error 2
make[1]: *** [check-am] Error 2
make: *** [check-recursive] Error 1

Check binary is Apple native

% make install
% file <install-path>/lib/libgdiplus.0.dylib
<install-path>/lib/libgdiplus.0.dylib: Mach-O 64-bit dynamically linked shared library arm64
@safern
Copy link

safern commented Mar 5, 2021

Thanks @sdmaclea -- @akoeplinger @directhex what should we do to get a libgdiplus for Apple Silicon published to homebrew?

@filipnavara
Copy link
Contributor

filipnavara commented Mar 5, 2021

Here's the log of the test failures:
test-suite.log

  • testbitmap - missing libjpeg dependency (seen as JPEG: no (Get it from http://freshmeat.net/projects/libjpeg) in configure)
  • testgifcodec - missing libgif (GIF: no (See http://sourceforge.net/projects/libgif))

There seems to be more issues with locating the dependent libraries:

checking for visibility __attribute__... no
checking for jpeg_destroy_decompress in -ljpeg... no
configure: WARNING: *** JPEG loader will not be built (JPEG library not found) ***
checking for TIFFReadScanline in -ltiff... no
checking for TIFFWriteScanline in -ltiff... no
checking for TIFFFlushData in -ltiff34... no
configure: WARNING: *** TIFF plug-in will not be built (TIFF library not found) ***
checking for DGifOpenFileName in -lgif... no
configure: WARNING: *** GIF loader will not be built (giflibrary not found) ***
checking for DGifOpenFileName in -lungif... no
configure: WARNING: *** GIF loader will not be built (ungiflibrary not found) ***

@seanarmstrong87
Copy link

seanarmstrong87 commented Dec 1, 2021

I did not know what to put for the --prefix flag so I left it blank, does that matter? Some tests failed similar to @filipnavara
After following instructions libgdiplus still does not work. In the code which uses it I still get error message "The type initializer for 'Gdip' threw an exception."
Any ideas?
I also get lots of warnings like this during the make

ld: warning: ignoring file /opt/X11/lib/libcairo.dylib, missing required architecture arm64 in file /opt/X11/lib/libcairo.dylib (2 slices)
ld: warning: ignoring file /opt/X11/lib/libfontconfig.dylib, missing required architecture arm64 in file /opt/X11/lib/libfontconfig.dylib (2 slices)
ld: warning: ignoring file /opt/X11/lib/libfreetype.dylib, missing required architecture arm64 in file /opt/X11/lib/libfreetype.dylib (2 slices)
ld: warning: ignoring file /opt/X11/lib/libpng16.dylib, missing required architecture arm64 in file /opt/X11/lib/libpng16.dylib (2 slices)
ld: warning: ignoring file /opt/X11/lib/libX11.dylib, missing required architecture arm64 in file /opt/X11/lib/libX11.dylib (2 slices)

@Whiletru3
Copy link

Hello
I try to compile libgdiplus for macOS arm64 (using this way to put into a nuget package : https://github.com/Whiletru3/libgdiplus-packaging ) and it should be the version 6.0.5.
I tried this way but I get this error :

 CC       testjpegcodec.o
testjpegcodec.c:24:10: fatal error: 'jpeglib.h' file not found
#include <jpeglib.h>
         ^~~~~~~~~~~
1 error generated.
make[2]: *** [testjpegcodec.o] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
Making check in src
make[1]: Nothing to be done for `check'.
Making check in tests
  CC       testjpegcodec.o
testjpegcodec.c:24:10: fatal error: 'jpeglib.h' file not found
#include <jpeglib.h>
         ^~~~~~~~~~~
1 error generated.
make[1]: *** [testjpegcodec.o] Error 1
make: *** [check-recursive] Error 1

libjpeg is installed with brew (in /opt/homebrew/... )

Do you have an idea on how to fix this ?
Thanks

@hbnrmx
Copy link

hbnrmx commented Mar 23, 2023

FWIW, I managed to enable JPEG support by running ./autogen.sh with
LDFLAGS="-L/opt/homebrew/opt/jpeg/lib" CPPFLAGS="-I/opt/homebrew/opt/jpeg/include"

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

6 participants