Compile ImageMagick from source with PNG support on OSX - macos

I need to compile it from sources. I followed step by step instruction to build it with jpeg and png support but ImageMagick didn't include PNG to delegates list however jpeg has been included. What is wrong with PNG?
Options used to compile and link:
PREFIX = /opt/im
EXEC-PREFIX = /opt/im
VERSION = 6.9.2
CC = gcc
CFLAGS = -g -O2 -Wall -mtune=haswell -fexceptions -D_FORTIFY_SOURCE=0 -D_THREAD_SAFE -pthread -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16
CPPFLAGS = -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -I/tmp/IM/ImageMagick-6.9.2-10/jpeg -I/tmp/IM/ImageMagick-6.9.2-10/magick -I/tmp/IM/ImageMagick-6.9.2-10/png -I/tmp/IM/ImageMagick-6.9.2-10/wand
PCFLAGS =
DEFS = -DHAVE_CONFIG_H
LDFLAGS = -L/tmp/IM/ImageMagick-6.9.2-10/jpeg/.libs -L/tmp/IM/ImageMagick-6.9.2-10/jpeg -L/tmp/IM/ImageMagick-6.9.2-10/magick -L/tmp/IM/ImageMagick-6.9.2-10/png/.libs -L/tmp/IM/ImageMagick-6.9.2-10/png -L/tmp/IM/ImageMagick-6.9.2-10/wand
LIBS =
CXX = g++
CXXFLAGS = -g -O2 -D_THREAD_SAFE -pthread
FEATURES = DPC Cipher
DELEGATES = mpeg jpeg

Here is how I would install ImageMagick from source on OSX.
1. Install Xcode
First, you are going to need the Apple compiler and development tools whatever you do. So, start the AppStore which looks like this:
and download Xcode for free - it looks like this:
2. Install Command Line Tools
Once you have Xcode installed, you need to install the command-line tools (i.e. clang, clang++, make) like this:
xcode-select --install
3. Choose Your Method - homebrew or a Life of Agony™
Now you need to choose how you are going to proceed. The simplest option, by miles and miles and miles, is to use homebrew. The other method is self-descriptive.
3a. homebrew Method
Go to the homebrew website and copy and paste the one-liner there into your Terminal - I won't show it here because it may change and I want you and future readers to use the current command. Once homebrew is installed, you just do this to choose your ImageMagick options:
brew options imagemagick
--with-fftw
Compile with FFTW support
--with-fontconfig
Build with fontconfig support
--with-ghostscript
Build with ghostscript support
--with-hdri
Compile with HDRI support
--with-jp2
Compile with Jpeg2000 support
--with-liblqr
Build with liblqr support
--with-librsvg
Build with librsvg support
--with-libwmf
Build with libwmf support
--with-little-cms
Build with little-cms support
--with-little-cms2
Build with little-cms2 support
--with-openexr
Build with openexr support
--with-openmp
Compile with OpenMP support
--with-pango
Build with pango support
--with-perl
enable build/install of PerlMagick
--with-quantum-depth-16
Compile with a quantum depth of 16 bit
--with-quantum-depth-32
Compile with a quantum depth of 32 bit
--with-quantum-depth-8
Compile with a quantum depth of 8 bit
--with-webp
Build with webp support
--with-x11
Build with x11 support
--without-freetype
Build without freetype support
--without-jpeg
Build without jpeg support
--without-libpng
Build without libpng support
--without-libtiff
Build without libtiff support
--without-magick-plus-plus
disable build/install of Magick++
--without-opencl
Disable OpenCL
and then having selected your options, you install with
brew install imagemagick --with-perl --with-librsvg
or whatever you want. Then you are finished and you don't need to read the following torture!
Later on, upgrades are simple:
brew update && brew upgrade --all
Problem-solving is simple:
brew doctor
Uninstallation is simple:
brew rm imagemagick
3b. Life of Agony™ Method
Ok, I see you sadly decided on a Life of Agony™, so be it. I hope you know tar, bash, environment variables, gzip, make, curl. Now would be a good time to think again and use homebrew after all....
Sure you want to proceed? Ok, the general idea is to decide what features you need, install the features first, then install ImageMagick.
4. Set up a build area and environment
Set up two directories and 2 environment vars in your $HOME/.profile. These will be the build area where you build software and the sw area where you install your local software to:
export MSBUILD=$HOME/build
export MSSW=$HOME/sw
Now source your profile into your current session with
. $HOME/.profile
or just log out and log back in so that the variables above take effect.
Next create the two directories:
mkdir "$MSBUILD" "$MSSW"
5. Consider Features you need
Now consider what features you need:
5.1 Feature = PNG Support
If you need PNG support, you need zlib first. In your web-browser, go to the zlib website and find the name of the latest version. Then in Terminal:
cd $MSBUILD
curl -O -J -L http://sourceforge.net/projects/libpng/files/zlib/1.2.8/zlib-1.2.8.tar.xz/download
which gets you this zlib-1.2.8.tar.xz (or similar) which you can unpack and install with:
tar xvfJ zlib*.tar.xz # Unzip and untar what you downloaded
cd zlib*[0-9] # Change directory to wherever it unpacked to
./configure --prefix="$MSSW" # Configure with the necessary prefix
make
make install
Now you want libpng which you do with:
curl -O -J -L http://sourceforge.net/projects/libpng/files/latest/download?source=files
which gets you this (or similar):
libpng-1.6.17.tar.xz
which you install with this command:
tar xvfJ libpng*xz # Unpack and untar whatever you downloaded
cd libpng*[0-9] # Change directory to wherever it unpacked to
./configure --prefix="$MSSW" # Configure with the necessary prefix
make
make install
5.2 Feature = TIFF Support
If you need TIFF support, use this:
cd $MSBUILD
curl -O -J -L ftp://ftp.remotesensing.org/libtiff/tiff-4.0.3.tar.gz
tar xvfz tiff*tar.gz # Unzip and untar what you downloaded
cd tiff*[0-9] # Change directory to wherever it unpacked to
./configure --prefix="$MSSW" # Configure with the necessary prefix
make
make install
5.3 Feature = WEBP Support
If you need WEBP support, use this:
cd $MSBUILD
curl -O -J -L http://downloads.webmproject.org/releases/webp/libwebp-0.4.3.tar.gz
tar xvfz libwebp*tar.gz # Unzip and untar what you downloaded
cd libwebp*[0-9] # Change directory to wherever it unpacked to
./configure --prefix="$MSSW" # Configure with the necessary prefix
make
make install
5.4 Feature = JPEG Support
If you need JPEG support, use this:
cd $MSBUILD
curl -O -J -L http://www.ijg.org/files/jpegsrc.v9a.tar.gz
tar xvfz jpeg*tar.gz # Unzip and untar what you downloaded
cd jpeg-9a # Change directory to wherever it unpacked to
./configure --prefix="$MSSW" # Configure with the necessary prefix
make
make install
5.5 Feature - X11 or X Windows
As OSX no longer ships with an X11 server, you will need to install one yourself if you wish to use X11. Now, if you had taken my advice and used homebrew, you would be able to do:
brew cask install xquartz
and you would be finished. But you chose the Life of Agony ™ option, so you will have to figure out how to install XQuartz yourself.
6. ImageMagick itself
Once you have all the features you want installed, you can install ImageMagick. Get your copy here, then install like this:
cd $MSBUILD
gunzip ImageMagick.tar.gz
tar -xvf ImageMagick.tar
cd ImageMagick-6.9.1-2 # or wherever the tar-file extracted to
Now choose your options. How do you know the options available? You run:
./configure --help
and you will get a daunting array of options like this:
`configure' configures ImageMagick 6.9.2-10 to adapt to many kinds of systems.
Usage: ./configure [OPTION]... [VAR=VALUE]...
To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE. See below for descriptions of some of the useful variables.
Defaults for the options are specified in brackets.
Configuration:
-h, --help display this help and exit
--help=short display options specific to this package
--help=recursive display the short help of all the included packages
-V, --version display version information and exit
-q, --quiet, --silent do not print `checking ...' messages
--cache-file=FILE cache test results in FILE [disabled]
-C, --config-cache alias for `--cache-file=config.cache'
-n, --no-create do not create output files
--srcdir=DIR find the sources in DIR [configure dir or `..']
Installation directories:
--prefix=PREFIX install architecture-independent files in PREFIX
[/usr/local]
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
[PREFIX]
By default, `make install' will install all the files in
`/usr/local/bin', `/usr/local/lib' etc. You can specify
an installation prefix other than `/usr/local' using `--prefix',
for instance `--prefix=$HOME'.
For better control, use the options below.
Fine tuning of the installation directories:
--bindir=DIR user executables [EPREFIX/bin]
--sbindir=DIR system admin executables [EPREFIX/sbin]
--libexecdir=DIR program executables [EPREFIX/libexec]
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
--datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
--datadir=DIR read-only architecture-independent data [DATAROOTDIR]
--infodir=DIR info documentation [DATAROOTDIR/info]
--localedir=DIR locale-dependent data [DATAROOTDIR/locale]
--mandir=DIR man documentation [DATAROOTDIR/man]
--docdir=DIR documentation root [DATAROOTDIR/doc/ImageMagick]
--htmldir=DIR html documentation [DOCDIR]
--dvidir=DIR dvi documentation [DOCDIR]
--pdfdir=DIR pdf documentation [DOCDIR]
--psdir=DIR ps documentation [DOCDIR]
Program names:
--program-prefix=PREFIX prepend PREFIX to installed program names
--program-suffix=SUFFIX append SUFFIX to installed program names
--program-transform-name=PROGRAM run sed PROGRAM on installed program names
X features:
--x-includes=DIR X include files are in DIR
--x-libraries=DIR X library files are in DIR
System types:
--build=BUILD configure for building on BUILD [guessed]
--host=HOST cross-compile to build programs to run on HOST [BUILD]
--target=TARGET configure for building compilers for TARGET [HOST]
Optional Features:
--disable-option-checking ignore unrecognized --enable/--with options
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--enable-silent-rules less verbose build output (undo: "make V=1")
--disable-silent-rules verbose build output (undo: "make V=0")
--enable-reproducible-build
enable reproducible build
--enable-dependency-tracking
do not reject slow dependency extractors
--disable-dependency-tracking
speeds up one-time build
--enable-ld-version-script
enable linker version script (default is enabled
when possible)
--enable-bounds-checking
enable run-time bounds-checking
--enable-osx-universal-binary
build universal binary on OS X [[default=no]]
--disable-openmp do not use OpenMP
--enable-opencl enable OpenCL support
--disable-largefile omit support for large files
--enable-shared[=PKGS] build shared libraries [default=yes]
--enable-static[=PKGS] build static libraries [default=yes]
--enable-fast-install[=PKGS]
optimize for fast installation [default=yes]
--disable-libtool-lock avoid locking (might break parallel builds)
--enable-delegate-build look for delegate libraries in build directory
--disable-deprecated exclude deprecated methods in MagickCore and
MagickWand APIs
--disable-installed Formally install ImageMagick under PREFIX
--disable-cipher disable enciphering and deciphering image pixels
--enable-zero-configuration
enable self-contained, embeddable,
zero-configuration ImageMagick
--enable-hdri accurately represent the wide range of intensity
levels found in real scenes
--disable-assert disable assert() statements in build
--enable-maintainer-mode
enable make rules and dependencies not useful (and
sometimes confusing) to the casual installer
--enable-hugepages enable 'huge pages' support
--enable-ccmalloc enable 'ccmalloc' memory debug support
--enable-efence enable 'efence' memory debug support
--enable-prof enable 'prof' profiling support
--enable-gprof enable 'gprof' profiling support
--enable-gcov enable 'gcov' profiling support
--disable-assert turn off assertions
--disable-docs disable building of documentation
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-gnu-ld assume the C compiler uses GNU ld [default=no]
--with-dmalloc use dmalloc, as in http://www.dmalloc.com
--with-gcc-arch=<arch> use architecture <arch> for gcc -march/-mtune,
instead of guessing
--includearch-dir=DIR ARCH specific include directory
--sharearch-dir=DIR ARCH specific config directory
--with-pkgconfigdir=DIR Path to the pkgconfig directory [LIBDIR/pkgconfig]
--without-threads disable threads support
--with-pic[=PKGS] try to use only PIC/non-PIC objects [default=use
both]
--with-aix-soname=aix|svr4|both
shared library versioning (aka "SONAME") variant to
provide on AIX, [default=aix].
--with-sysroot[=DIR] Search for dependent libraries within DIR (or the
compiler's sysroot if not specified).
--with-modules enable building dynamically loadable modules
--with-method-prefix=PREFIX
prefix MagickCore API methods
--with-quantum-depth=DEPTH
number of bits in a pixel quantum (default 16)
--with-cache=THRESHOLD set pixel cache threshhold in MB (default available
memory)
--with-frozenpaths freeze delegate paths
--without-magick-plus-plus
disable build/install of Magick++
--with-package-release-name=NAME
encode this name into the shared library
--with-perl enable build/install of PerlMagick
--with-perl-options=OPTIONS
options to pass on command-line when generating
PerlMagick build file
--with-jemalloc enable jemalloc memory allocation library support
--with-umem enable umem memory allocation library support
--with-libstdc=DIR use libstdc++ in DIR (for GNU C++)
--without-bzlib disable BZLIB support
--with-x use the X Window System
--without-zlib disable ZLIB support
--with-apple-font-dir=DIR
Apple font directory
--with-autotrace enable autotrace support
--without-dps disable Display Postscript support
--with-dejavu-font-dir=DIR
DejaVu font directory
--without-fftw disable FFTW support
--without-fpx disable FlashPIX support
--without-djvu disable DjVu support
--without-fontconfig disable fontconfig support
--without-freetype disable Freetype support
--with-gslib enable Ghostscript library support
--with-fontpath=DIR prepend to default font search path
--with-gs-font-dir=DIR Ghostscript font directory
--with-gvc enable GVC support
--without-jbig disable JBIG support
--without-jpeg disable JPEG support
--without-lcms disable lcms (v1.1X) support
--without-openjp2 disable OpenJP2 support
--without-lqr disable Liquid Rescale support
--without-lzma disable LZMA support
--without-openexr disable OpenEXR support
--without-pango disable PANGO support
--without-png disable PNG support
--with-rsvg enable RSVG support
--without-tiff disable TIFF support
--without-webp disable WEBP support
--with-windows-font-dir=DIR
Windows font directory
--with-wmf enable WMF support
--without-xml disable XML support
Some influential environment variables:
CC C compiler command
CFLAGS C compiler flags
LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
nonstandard directory <lib dir>
LIBS libraries to pass to the linker, e.g. -l<library>
CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
you have headers in a nonstandard directory <include dir>
CPP C preprocessor
CXX C++ compiler command
CXXFLAGS C++ compiler flags
PKG_CONFIG path to pkg-config utility
PKG_CONFIG_PATH
directories to add to pkg-config's search path
PKG_CONFIG_LIBDIR
path overriding pkg-config's built-in search path
LT_SYS_LIBRARY_PATH
User-defined run-time library search path.
CXXCPP C++ preprocessor
XMKMF Path to xmkmf, Makefile generator for X Window System
ZLIB_CFLAGS C compiler flags for ZLIB, overriding pkg-config
ZLIB_LIBS linker flags for ZLIB, overriding pkg-config
AUTOTRACE_CFLAGS
C compiler flags for AUTOTRACE, overriding pkg-config
AUTOTRACE_LIBS
linker flags for AUTOTRACE, overriding pkg-config
fftw3_CFLAGS
C compiler flags for fftw3, overriding pkg-config
fftw3_LIBS linker flags for fftw3, overriding pkg-config
ddjvuapi_CFLAGS
C compiler flags for ddjvuapi, overriding pkg-config
ddjvuapi_LIBS
linker flags for ddjvuapi, overriding pkg-config
FONTCONFIG_CFLAGS
C compiler flags for FONTCONFIG, overriding pkg-config
FONTCONFIG_LIBS
linker flags for FONTCONFIG, overriding pkg-config
FREETYPE_CFLAGS
C compiler flags for FREETYPE, overriding pkg-config
FREETYPE_LIBS
linker flags for FREETYPE, overriding pkg-config
GVC_CFLAGS C compiler flags for GVC, overriding pkg-config
GVC_LIBS linker flags for GVC, overriding pkg-config
LCMS2_CFLAGS
C compiler flags for LCMS2, overriding pkg-config
LCMS2_LIBS linker flags for LCMS2, overriding pkg-config
LIBOPENJP2_CFLAGS
C compiler flags for LIBOPENJP2, overriding pkg-config
LIBOPENJP2_LIBS
linker flags for LIBOPENJP2, overriding pkg-config
LQR_CFLAGS C compiler flags for LQR, overriding pkg-config
LQR_LIBS linker flags for LQR, overriding pkg-config
LZMA_CFLAGS C compiler flags for LZMA, overriding pkg-config
LZMA_LIBS linker flags for LZMA, overriding pkg-config
OPENEXR_CFLAGS
C compiler flags for OPENEXR, overriding pkg-config
OPENEXR_LIBS
linker flags for OPENEXR, overriding pkg-config
PANGO_CFLAGS
C compiler flags for PANGO, overriding pkg-config
PANGO_LIBS linker flags for PANGO, overriding pkg-config
PNG_CFLAGS C compiler flags for PNG, overriding pkg-config
PNG_LIBS linker flags for PNG, overriding pkg-config
RSVG_CFLAGS C compiler flags for RSVG, overriding pkg-config
RSVG_LIBS linker flags for RSVG, overriding pkg-config
CAIRO_SVG_CFLAGS
C compiler flags for CAIRO_SVG, overriding pkg-config
CAIRO_SVG_LIBS
linker flags for CAIRO_SVG, overriding pkg-config
XML_CFLAGS C compiler flags for XML, overriding pkg-config
XML_LIBS linker flags for XML, overriding pkg-config
Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
Report bugs to <http://www.imagemagick.org>.
Once you have chosen your options, install with a command that looks like this:
./configure --prefix="$MSSW" --with-modules --disable-docs --without-x --enable-hdri=yes --with-quantum-depth=16
make
make install
Now add $MSSW/bin to your PATH in $HOME/.profile.
export PATH=$HOME/sw/bin:${PATH}
And log out and back in again to make the new PATH active (or dot in your profile, if you know what that means).
7. Test the installation
Now test it with:
identify -version
Version: ImageMagick 6.9.2-10 Q16 x86_64 2015-12-23 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2016 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC Modules
Delegates (built-in): bzlib cairo fontconfig freetype jng jp2 jpeg lcms ltdl lzma png rsvg tiff webp x xml zlib

Related

osx - C++14 compiler not detected, multiple versions of gcc when compiling graph-tool in anaconda

My ultimate goal is to get python package graph_tool working on my system and also on ipynb if possible. I have already brew install graph-tool, as indicated here, but that's still insufficient.
So I follow conda instructions here, and I make decent progress, until I encounter a compiler issue with the configuration.
$ conda create -n py36env python=3.6.3 anaconda
(py36env) $ conda install -c conda-forge cgal
... and so forth with the other required libraries
(py36env) Tams-MacBook-Pro:graph-tool-2.25 tamtam$ ./configure --prefix=/Users/tamtam/anaconda3/envs/py36env/ --with-python-module-path=/Users/tamtam/anaconda3/envs/py36env/lib/python3.6/site-packages
.
.
.
checking whether g++ supports C++14 features by default... no
checking whether g++ supports C++14 features with -std=gnu++14... no
checking whether g++ supports C++14 features with -std=gnu++1y... no
configure: error: *** A compiler with support for C++14 language features is required.
I'm not very familiar with compiler things, but I check my system as follows:
(py36env) Tams-MacBook-Pro:graph-tool-2.25 tamtam$ conda list | grep gcc
gcc 4.8.5 8
And outside of the conda env:
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/Users/tamtam/anaconda3/envs/py36env/bin/../libexec/gcc/x86_64-apple-darwin11.4.2/4.8.5/lto-wrapper
Target: x86_64-apple-darwin11.4.2
Configured with: ./configure --prefix=/Users/ray/mc-x64-3.5/conda-bld/gcc-4.8_1477649012852/
Thread model: posix
gcc version 4.8.5 (GCC)
And with Homebrew
$ brew list --versions | grep gcc
gcc 7.1.0 7.2.0
$ /usr/local/bin/gcc-7 --version
gcc-7 (Homebrew GCC 7.2.0) 7.2.0
$ echo $PATH
/Users/tamtam/anaconda3/bin:/Users/tamtam/anaconda/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin
So my questions are: EDITS INCLUDED
1) What's the difference between the conda gcc 4.8.5 and Homebrew gcc 7.2 on my system? I'm confused because they're each up-to-date packages.
EDIT: Nowhere online that I perused explicitly states this, but I am understanding (aka educated guess bc it's 3am and I need sleep) conda gcc 4.8.5 to just be equivalent to brew gcc 4.8.5, and that Anaconda is just way behind on developing an 'official' gcc supporting C++14. In the meantime I conda install -c salford_systems gcc-5 and ./configure seems to find itself a C++14 compiler. YAY (but this also led me to a new problem T.B.A.)
NOTE: I had also tried running the ./configure file with both conda gcc 4.8.5 and brew gcc 7.2.0 (switching of default gcc compiler guided here), but still same error of ./configure not finding C++14 compile (so ignore this)
2) I also have Xcode 8.3.3 that also comes with clang, which is what gcc is symlinked to... ?? No idea about the setup/relation
3) How can I adjust my system (for example, paths) so that the configuration process will detect a C++14 compiler? EDIT: resolved per 1)
(This solution is also included within the edits at the bottom of my question.)
Nowhere online that I perused explicitly states this, but I am understanding (aka educated guess bc it's 3am and I need sleep) conda gcc 4.8.5 to just be equivalent to brew gcc 4.8.5, and that Anaconda is just way behind on developing an 'official' gcc supporting C++14. In the meantime I conda install -c salford_systems gcc-5 and ./configure seems to find itself a C++14 compiler. YAY (but this also led me to a new problem)
NOTE: I had also tried running the ./configure file with both conda gcc 4.8.5 and brew gcc 7.2.0 (switching of default gcc compiler guided here), but still same error of ./configure not finding C++14 compile arises (so ignore this)
As a rule of thumb, if a product provides its own build tools (compiler, C headers, static libraries, include/library paths etc) instead of using the system's ones, you should use those when building things to use within its environment.
That's because, depending on include files, compiler, compiler version, compiler flags, predefined macros etc the same sources and libraries built with different toolchains can be binary incompatible. This goes double for C++ where there are no ABI standards at all. (In C, there are de facto ones for most platforms where there are competing compilers due to the need to do system calls.)
Now, what you have on your system:
The system's stock gcc (if any) is at /usr/bin (so includes are at /usr/include, static libraries at /usr/lib etc)
Homebrew's gcc 7.2 at /usr/local/bin (includes are probably at /usr/local/include)
Anaconda also has a gcc package that, if installed, would reside somewhere like /Users/<login>/anaconda3/envs/<env name>/bin
If an environment provides an own toolchain, it provides some way to make build scripts select that toolchain when building things. A common way is to set relevant environment variables (PATH, INCLUDE, LIB) - either directly or through some tool that the environment provides. Homebrew executables reside in /usr/local/bin which is always present in UNIX PATH as per the FHS; Anaconda adds itself to PATH whenever its environment is activated.
So, as you yourself guessed, since Anaconda provides its own gcc packages (thus enforces the compatibility of their output with its binary packages via package metadata - if there are known incompatibilities, the installation will fail due to requirement conflicts), you need to install one that meets graph-tool requirements -- which is gcc 5, available via gcc-5 package from salford_systems channel. Then specify --prefix as you already have.
You may need to install other dependencies, too, if you didn't already or you need optional features that they're required for.

How to build Sqlite binaries in Debug/Release mode

How can we build the SQLite binary in Debug or Release mode?
I have downloaded the source code (sqlite-autoconf-3120000.tar.gz) from https://www.sqlite.org/download.html. Configure file provided by it doesnot support --enable-debug option.
Result of ./configure --help is as follows:
anshu#vijayakumart:~/Git/sqlite-autoconf-3120000$ ./configure --help
`configure' configures sqlite 3.12.0 to adapt to many kinds of systems.
Usage: ./configure [OPTION]... [VAR=VALUE]...
To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE. See below for descriptions of some of the useful variables.
Defaults for the options are specified in brackets.
Configuration:
-h, --help display this help and exit
--help=short display options specific to this package
--help=recursive display the short help of all the included packages
-V, --version display version information and exit
-q, --quiet, --silent do not print `checking ...' messages
--cache-file=FILE cache test results in FILE [disabled]
-C, --config-cache alias for `--cache-file=config.cache'
-n, --no-create do not create output files
--srcdir=DIR find the sources in DIR [configure dir or `..']
Installation directories:
--prefix=PREFIX install architecture-independent files in PREFIX
[/usr/local]
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
[PREFIX]
By default, `make install' will install all the files in
`/usr/local/bin', `/usr/local/lib' etc. You can specify
an installation prefix other than `/usr/local' using `--prefix',
for instance `--prefix=$HOME'.
For better control, use the options below.
Fine tuning of the installation directories:
--bindir=DIR user executables [EPREFIX/bin]
--sbindir=DIR system admin executables [EPREFIX/sbin]
--libexecdir=DIR program executables [EPREFIX/libexec]
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
--datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
--datadir=DIR read-only architecture-independent data [DATAROOTDIR]
--infodir=DIR info documentation [DATAROOTDIR/info]
--localedir=DIR locale-dependent data [DATAROOTDIR/locale]
--mandir=DIR man documentation [DATAROOTDIR/man]
--docdir=DIR documentation root [DATAROOTDIR/doc/sqlite]
--htmldir=DIR html documentation [DOCDIR]
--dvidir=DIR dvi documentation [DOCDIR]
--pdfdir=DIR pdf documentation [DOCDIR]
--psdir=DIR ps documentation [DOCDIR]
Program names:
--program-prefix=PREFIX prepend PREFIX to installed program names
--program-suffix=SUFFIX append SUFFIX to installed program names
--program-transform-name=PROGRAM run sed PROGRAM on installed program names
System types:
--build=BUILD configure for building on BUILD [guessed]
--host=HOST cross-compile to build programs to run on HOST [BUILD]
Optional Features:
--disable-option-checking ignore unrecognized --enable/--with options
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--enable-silent-rules less verbose build output (undo: "make V=1")
--disable-silent-rules verbose build output (undo: "make V=0")
--disable-largefile omit support for large files
--enable-dependency-tracking
do not reject slow dependency extractors
--disable-dependency-tracking
speeds up one-time build
--enable-shared[=PKGS] build shared libraries [default=yes]
--enable-static[=PKGS] build static libraries [default=yes]
--enable-fast-install[=PKGS]
optimize for fast installation [default=yes]
--disable-libtool-lock avoid locking (might break parallel builds)
--enable-editline use BSD libedit
--enable-readline use readline
--enable-threadsafe build a thread-safe library [default=yes]
--enable-dynamic-extensions
support loadable extensions [default=yes]
--enable-fts5 include fts5 support [default=no]
--enable-json1 include json1 support [default=no]
--enable-static-shell statically link libsqlite3 into shell tool
[default=yes]
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-pic[=PKGS] try to use only PIC/non-PIC objects [default=use
both]
--with-aix-soname=aix|svr4|both
shared library versioning (aka "SONAME") variant to
provide on AIX, [default=aix].
--with-gnu-ld assume the C compiler uses GNU ld [default=no]
--with-sysroot[=DIR] Search for dependent libraries within DIR (or the
compiler's sysroot if not specified).
Some influential environment variables:
CC C compiler command
CFLAGS C compiler flags
LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
nonstandard directory <lib dir>
LIBS libraries to pass to the linker, e.g. -l<library>
CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
you have headers in a nonstandard directory <include dir>
LT_SYS_LIBRARY_PATH
User-defined run-time library search path.
CPP C preprocessor
Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
Is there any way to specify Debug/Release mode while generating binaries?
Compilation options must be defined as preprocessor symbols:
configure CPPFLAGS=-DSQLITE_DEBUG

How to override default linker compiling with configure?

I need to install a package (ROOT) from source on OSX using GCC 4.7.3 as a compiler. Default compiler on OSX is clang, so I look to configure command options to change it. I see that I can change it:
with compiler options, prefix with --with-, overrides default value
cc alternative C compiler and options to be used
cxx alternative C++ compiler and options to be used
But when I run:
./configure --with-cxx=g++ --with-cc=gcc
I see:
Checking for C compiler ... gcc
Checking for C++ compiler ... g++
Checking for linker (LD) ... clang++
So it trying to compile with gcc and link with clang, this obviously leads to failure. But I can't find an option in configure how to change linker used by make.
Is there a default options of configure to change linker? Something like --with-cxxlinker.
If not - how can I find and change the linker used by specific package?
The recommended way of building ROOT from source is to use git and obtain the most recent production version available. As of today that is version 5.34.19.
Open Terminal.app (then use each of the commands in succession):
cd ~/desktop && mkdir root
git clone http://root.cern.ch/git/root.git && cd root
./configure
make
make install
The nice thing about using git is that it contains a complete source tree for all systems (72 MB). You shouldn't need to use any special ./configure commands (unless you want to use add-on components).
You could also install the Mac Ports version by using the command:
sudo port install root

How do I compile and run GCC 4.9.x?

I'm running debian wheezy and wanted to upgrade from GCC 4.7.2 to GCC 4.9.0.
As per these instructions I installed libgmp-dev, libmpfr-dev and libmpc-dev (my package manager gave me versions 2:5.0.5+dfsg-2, 3.1.0-5 and 0.9-4 respectively) and ran the following to compile gcc (note that in my case it was 4.9.0 instead of 4.6.2):
tar xzf gcc-4.6.2.tar.gz
cd gcc-4.6.2
./contrib/download_prerequisites
cd ..
mkdir objdir
cd objdir
$PWD/../gcc-4.6.2/configure --prefix=$HOME/gcc-4.6.2
make
make install
I now have a objdir directory full of stuff, but where is g++, and where should I put this directory?
I'm guessing I should move it to usr/local and add something to my PATH variable, but I don't know what exactly, and how to make sure it is searched before my old gcc install.
After doing these commands (note the --prefix option of configure)
$PWD/../gcc-4.9.0/configure --prefix=$HOME/gcc-4.9.0
make install
the new gcc will be installed in $HOME/gcc-4.9.0 directory (there should be subdirectories like bin, lib, share inside it).
Full path to gcc will be $HOME/gcc-4.9.0/bin/gcc, and g++ (which is symlink to gcc) will be here: $HOME/gcc-4.9.0/bin/g++.
There can be no separate g++ in objdir because gcc compiler driver implements drivers for several languages; the mode (C or C++) is selected based on argv[0] (name of binary, which was used to run driver: gcc or g++; this mode also affects linking flags) and on source file extensions (gcc accepts both C and C++ programs as input for compilation into object files). So, g++ may be generated as symlink by make install, and the place to store generated symlink is $prefix/bin.
After building the GCC and installing it in the $HOME/gcc-4.9.0 directory, you can use it; but default system gcc will be not updated. Update of distributive gcc should be done via distributive tools (apt, dpkg-build, etc). Current prebuild version of system-wide gcc for Wheezy is 4.7.2, 4.8.2 for Jessie and Sid and 4.9-2 for "Experimental".

Basic UNIX configure/make/sudo make install question

I have learned to compile my own source over the years but always left some of the process to "mystery". I'm running into a bitch of a time getting ImageMagick and its myriad dependencies to work correctly on a PowerPC Mac OS X Server.
In setting flags for ./compile where does one typically uncover the various options (flags) that can be set and the descriptions of what each does?!?
For example, in the case of libwmf I'm using:
./configure --without-expat --with-xml --with-png=/usr/X11
...but not really knowing what each flag does. Now I'm having a png compatibility problem and want to find out why --with-png=/usr/X11 flag is being specified in install script I'm following...but can't find any documentation, etc. Any help?
Even a general response of how the UNIX Guru approaches this problem would be helpful.
./configure --help will give you the list of options that a configure script supports. To find out details about each option or the arguments you have to supply in particular cases, you will have to read the installation documentation of the particular package, if it has one. There are certain conventions that you will pick up over time, but they are just conventions. If you build a rather complicated package such as ImageMagick that pulls in dozens of library dependencies, and you use a less-than-common platform such as Mac with hand-compiled stuff, you might really have to dig deep and hard in some cases.
On my Mac, /usr/X11/lib contains a lot of libraries, including libpng.dylib and libpng.3.44.0.dylib in particular. Do you have those libraries? If not, you need to get X11 installed onto your Mac, and things are likely to go more smoothly.
MacOS X for Intel
I've downloaded ImageMagick 6.6.9-9 and configured, built and checked (but not installed) it with minimal issues. I have XCode 4 on my machine - and the only special option I used with ./configure was:
CC=/usr/bin/gcc ./configure
to ensure it picked up the system-provided GCC (4.2.1), not my private version of GCC 4.6.0. (A configuration test failed - for the sizeof(off_t) - because of a library issue. Using the system C compiler avoided that problem.) The ImageMagick configuration printed out:
ImageMagick is configured as follows. Please verify that this configuration
matches your expectations.
Host system type: x86_64-apple-darwin10.7.0
Build system type: x86_64-apple-darwin10.7.0
Option Value
-------------------------------------------------------------------------------
Shared libraries --enable-shared=yes yes
Static libraries --enable-static=yes yes
Module support --with-modules=no no
GNU ld --with-gnu-ld=no no
Quantum depth --with-quantum-depth=16 16
High Dynamic Range Imagery
--enable-hdri=no no
Delegate Configuration:
BZLIB --with-bzlib=yes yes
Autotrace --with-autotrace=no no
Dejavu fonts --with-dejavu-font-dir=default none
DJVU --with-djvu=yes no
DPS --with-dps=yes no
FFTW --with-fftw=yes no
FlashPIX --with-fpx=yes no
FontConfig --with-fontconfig=yes no
FreeType --with-freetype=yes yes
GhostPCL None pcl6 (unknown)
GhostXPS None gxps (unknown)
Ghostscript None gs (unknown)
Ghostscript fonts --with-gs-font-dir=default none
Ghostscript lib --with-gslib=no no
Graphviz --with-gvc=yes no
JBIG --with-jbig=yes no
JPEG v1 --with-jpeg=yes no (failed tests)
JPEG-2000 --with-jp2=yes no
LCMS v1 --with-lcms=yes no
LCMS v2 --with-lcms2=yes no
LQR --with-lqr=yes no
LZMA --with-lzma=yes no
Magick++ --with-magick-plus-plus=yes yes
OpenEXR --with-openexr=yes no
PERL --with-perl=no no
PNG --with-png=yes yes
RSVG --with-rsvg=yes no
TIFF --with-tiff=yes no
WEBP --with-webp=yes no
Windows fonts --with-windows-font-dir= none
WMF --with-wmf=yes no
X11 --with-x= yes
XML --with-xml=yes yes
ZLIB --with-zlib=yes yes
X11 Configuration:
X_CFLAGS =
X_PRE_LIBS = -lSM -lICE
X_LIBS = -L/usr/X11/lib -R/usr/X11/lib
X_EXTRA_LIBS =
Options used to compile and link:
PREFIX = /usr/local
EXEC-PREFIX = /usr/local
VERSION = 6.6.9
CC = /usr/bin/gcc -std=gnu99 -std=gnu99
CFLAGS = -D_THREAD_SAFE -D_THREAD_SAFE -pthread -fopenmp -g -O2 -Wall -D_THREAD_SAFE -pthread
CPPFLAGS = -I/usr/local/include/ImageMagick
PCFLAGS = -fopenmp
DEFS = -DHAVE_CONFIG_H
LDFLAGS = -L/usr/X11/lib -R/usr/X11/lib
MAGICK_LDFLAGS = -L/usr/local/lib -L/usr/X11/lib -R/usr/X11/lib
LIBS = -lMagickCore -lfreetype -lpng -lXext -lXt -lSM -lICE -lX11 -lbz2 -lxml2 -lz -lm -lgomp -lclparser -Wl,-framework,OpenCL -L/System/Library/Frameworks/OpenCL.framework/Versions/A/Libraries -lm -lpthread
CXX = g++
CXXFLAGS = -g -O2 -D_THREAD_SAFE -pthread
FEATURES = OpenMP
Some of the tests failed - I expect that was because I was not actually running an X11 server on the machine at the time. I'm not immediately going to investigate - you are running into problems at a much earlier stage.
MacOS X for PowerPC
As you can see, this is for Snow Leopard (10.6.7) on Intel x86/64. If you are running with Leopard (10.5.x) on PowerPC, you probably have an older XCode and libraries etc, but it would be surprising if the configuration process does not work if you have the XCode on the machine - and X11 installed.
Addressing your question about the flags in the invocation:
./configure --without-expat --with-xml --with-png=/usr/X11
In general, you cannot be certain what each flag does because the
maintainer of the package is completely free to have the flags do whatever
they want. There are certain conventions, but many are not well
understood by the package maintainers so you cannot fully rely on them.
Generally, the --with and --without are simply used to determine
what features to compile in. For example, if you do not have libexpat
installed, you can set --without-expat to complete the build which would otherwise fail.
One would suspect that the default for the package is to attempt
to build with certain features that require libexpat, and the
configury will fail if libexpat is not present, so you set
--without-expat to turn off those features.
The --with-png option with an argument is, IMO, a completely
untrustworthy kludge. I've never seen a package where it
actually works. Typically, all the configure script does
is take your /usr/X11 argument and add it (with "-L"
prepended) to LDFLAGS. The idea is that this will cause
the linker to use /usr/X11/libpng.so and not some other
version of libpng, but the simple fact is that if you
have libpng somewhere else on your system and that other
location is in your LDFLAGS, it will be used. In other
words, if you have /usr/lib/foo.so and /usr/lib/bar.so
and /usr/other/lib/foo.so and /usr/other/lib/bar.so,
there is simply no way to use /usr/lib/foo.so and /usr/lib/other/bar.so
short of deleting one of the libraries. Rather than specifying
a path as an argument to --with-png, you are probably better
off doing "--with-png LDFLAGS='-L/path -L/path2'", or just
ensure that your system is built so that the desired paths are
searched by the linker. (eg, specify the paths in /etc/ld.so.conf
or in /etc/ld.so.conf.d)

Resources