On macOS, with the developer command line tools or Xcode installed, a number of additional packages are present that Graphviz can use. However, the autotools build cannot find them. Configuration defaults to requiring expat, so one either specifies --without-expat, or sets
EXPAT_CFLAGS=-L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib and EXPAT_LIBS=-lexpat to reference /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib
CMake appears to be able to find EXPAT on macOS. Could autotools also look for expat in command line tools automatically?
I am on a Mac running Sonoma. I start with a cloned graphviz repo, run ./autogen.sh, and then ./configure. The log below shows the error. Configuration is not looking for expat in the Command Line Tools or Xcode locations.
Interestingly, if I use CMake, expat is found in the CLT library.
3700 configure:25046: checking for expat
3701 configure:25053: $PKG_CONFIG --exists --print-errors "expat"
3702 Package expat was not found in the pkg-config search path.
3703 Perhaps you should add the directory containing `expat.pc'
3704 to the PKG_CONFIG_PATH environment variable
3705 No package 'expat' found
3706 configure:25056: $? = 1
3707 configure:25070: $PKG_CONFIG --exists --print-errors "expat"
3708 Package expat was not found in the pkg-config search path.
3709 Perhaps you should add the directory containing `expat.pc'
3710 to the PKG_CONFIG_PATH environment variable
3711 No package 'expat' found
3712 configure:25073: $? = 1
3713 configure:25087: result: no
3714 No package 'expat' found
3715 configure:25103: error: Package requirements (expat) were not met:
3716
3717 No package 'expat' found
3718
3719 Consider adjusting the PKG_CONFIG_PATH environment variable if you
3720 installed software in a non-standard prefix.
3721
3722 Alternatively, you may set the environment variables EXPAT_CFLAGS
3723 and EXPAT_LIBS to avoid the need to call pkg-config.
3724 See the pkg-config man page for more details.
When I first started using Graphviz on my Mac several years ago, I downloaded the source, ran ./configure --with-quartz; make; sudo make install.
I never installed expat, so I do not know if ./configure was not requiring it or if it was finding it in the command line tools.
This past summer, I began looking at building the macOS Graphviz.app. I started from a cloned Graphviz repo. I installed the autotools to build with ./autogen.sh. During this time, I discovered that ./configure needed expat, which I found in the Command Line Tools.
Setting LIBS and LDFLAGS to point to the CLT libraries for ./configure is not sufficient to resolve expat.
I have to specify —without-expat or —with-expat=no. Not specifying either requires setting the EXPAT environment variables for expat to be found.
Just tested running ./configure with graphviz-7.1.0 and graphviz-8.1.0. Sometime between these two the resolution of expat changed. In graphviz 7.1, without specifying any option regarding expat, it is found and included in graphviz. In 8.1, it is not found and the configure fails.
graphviz-7.1.0
configure:23995: checking for expat-config
configure:24028: result: no
configure:24063: checking expat.h usability
configure:24063: gcc -c -g -O2 -Wall -Wextra -Wmissing-include-dirs -Wswitch-default -Wfloat-equal -Wundef -Wshad
ow -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wconversion -Wstrict-prototypes -Wmissing-prototypes -Wnested
-externs -fno-common -Wall -I/usr/local/include conftest.c >&5
configure:24063: $? = 0
configure:24063: result: yes
configure:24063: checking expat.h presence
configure:24063: gcc -E -I/usr/local/include conftest.c
configure:24063: $? = 0
configure:24063: result: yes
configure:24063: checking for expat.h
configure:24063: result: yes
configure:24077: checking for main in -lexpat
configure:24096: gcc -o conftest -g -O2 -Wall -Wextra -Wmissing-include-dirs -Wswitch-default -Wfloat-equal -Wund
ef -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wconversion -Wstrict-prototypes -Wmissing-prototypes
-Wnested-externs -fno-common -Wall -I/usr/local/include -L/usr/local/lib -Wl,-headerpad_max_install_names con
ftest.c -lexpat >&5
conftest.c:76:6: warning: a function declaration without a prototype is deprecated in all versions of C [-Wstrict
-prototypes]
main ()
^
void
conftest.c:77:1: warning: all paths through this function will call itself [-Winfinite-recursion]
{
^
2 warnings generated.
configure:24096: $? = 0
configure:24105: result: yes
graphviz-8.1.0 (and later), note that its absence is a failure:
configure:23680: checking for EXPAT
configure:23687: $PKG_CONFIG --exists --print-errors "expat"
Package expat was not found in the pkg-config search path.
Perhaps you should add the directory containing `expat.pc'
to the PKG_CONFIG_PATH environment variable
No package 'expat' found
configure:23690: $? = 1
configure:23704: $PKG_CONFIG --exists --print-errors "expat"
Package expat was not found in the pkg-config search path.
Perhaps you should add the directory containing `expat.pc'
to the PKG_CONFIG_PATH environment variable
No package 'expat' found
configure:23707: $? = 1
configure:23721: result: no
No package 'expat' found
configure:23737: error: Package requirements (expat) were not met:
No package 'expat' found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables EXPAT_CFLAGS
and EXPAT_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.