configure script cannot find libxml2 on mac - macos

when I execute
./configure
...
checking for libxml-2.0... no
configure: error: Library libxml2 not found, install library or build without (using --disable-xml).
I installed libxml2 with brew and checked a lot of articles, but nothing helped so far.
UPDATE
./configure --help
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
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
libxml2_CFLAGS
C compiler flags for libxml2, overriding pkg-config
libxml2_LIBS
linker flags for libxml2, overriding pkg-config

homebrew installs libxml2 as "keg only" which means it is not symlinked to the normal /usr/local/include and /usr/local/lib directories... which means nothing can find it without help. You can get all the above info by running:
brew info libxml2
If you run:
brew ls libxml2
it will tell you the full paths to all the files in that package.
If you also run:
./configure --help
it should tell you what environment variables you need to set in order to find libxml2 So, armed with these last two pieces of info, you should be able to work out what you need to set and how.
I note there is a pkg-config file listed for libxml2 by homebrew at:
/usr/local/Cellar/libxml2/2.9.10/lib/pkgconfig/libxml-2.0.pc
which is also available via a non-version-specific symlink as:
/usr/local/opt/libxml2/lib/pkgconfig/libxml-2.0.pc
so, if you have installed pkg-config with homebrew, like this:
brew install pkg-config
the solution may be just to add the path for that to your PKG_CONFIG_PATH with:
export PKG_CONFIG_PATH=/usr/local/opt/libxml2/lib/pkgconfig:$PKG_CONFIG_PATH
and then to rerun your configure script.
Note: It is only after installing pkg-config (via brew) that homebrew will display pkg-config related "caveats" for many affected packages e.g. libffi:
==> Caveats
libffi is keg-only, which means it was not symlinked into /usr/local,
because some formulae require a newer version of libffi.
For compilers to find libffi you may need to set:
export LDFLAGS="-L/usr/local/opt/libffi/lib"
For pkg-config to find libffi you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig"
Unfortunately, however, this appears not to be the case for libxml2 for some reason. (Related homebrew issue: "libxml2 install path".)

Related

How to specify a gcc path in pip command?

I am trying to install cupy 5.0.0. cupy5.0.0 needs gcc version not more than 7. My deafault gcc is gcc-9. I cannot use conda environment. Also i dont have sudo permission to change /usr/bin/gcc to point to gcc-7. Is there any way to pass gcc path to pip command?
You can use CXX, CC and LD environment variables to specify executable names or full paths to C++ and C compilers, and the linker.
Specify the variables only for one command:
CXX=g++-7 CC=gcc-7 LD=g++-7 pip install ...
Alternatively:
export CXX=g++-7
export CC=gcc-7
export LD=g++-7
pip install ...
You can also pass extra compiler and linker options in CXXFLAGS, CFLAGS, LDFLAGS. Preprocessor options (e.g. include directories) go in CPPFLAGS.

How to get pkg-config to use PKG_CONFIG_PATH?

I've written a small library and I'm trying to set it up to be usable with pkg-config, for those in my organization who might need to make use of it later. So my installer places a .pc file in /usr/local/lib/pkgconfig, and I've recently discovered that for some reason this isn't in the default list of directories that pkg-config scans for its pc files, despite /usr/local being the canonical prefix for locally-compiled software. So, I need to add /usr/local/lib/pkgconfig to PKG_CONFIG_PATH.
However, I'm finding that despite claims in the man page, pkg-config's own error message and everywhere online, pkg-config doesn't actually look at PKG_CONFIG_PATH. The error message tells me to add /usr/local/lib/pkgconfig (which contains the .pc file I'm looking for) to PKG_CONFIG_PATH, when I've clearly already done that.
[chris#delphinus-a pkgconfig]$ pwd
/usr/local/lib/pkgconfig
[chris#delphinus-a pkgconfig]$ ls
libexample.pc
[chris#delphinus-a pkgconfig]$ export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
[chris#delphinus-a pkgconfig]$ echo $PKG_CONFIG_PATH
/usr/local/lib/pkgconfig
[chris#delphinus-a pkgconfig]$ pkg-config --cflags libexample
Package libexample was not found in the pkg-config search path.
Perhaps you should add the directory containing `libexample.pc'
to the PKG_CONFIG_PATH environment variable
Package 'libexample', required by 'virtual:world', not found
[chris#delphinus-a pkgconfig]$ echo $PKG_CONFIG_PATH
/usr/local/lib/pkgconfig
[chris#delphinus-a pkgconfig]$ pkg-config --variable pc_path pkg-config
/usr/lib64/pkgconfig:/usr/share/pkgconfig
[chris#delphinus-a pkgconfig]$ pkg-config --version
1.6.3
The contents of libexample.pc:
prefix=/usr/local
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/include
Name: libexample
Description: example library.
Libs: -L${libdir} -lpthread -ltimeutil -lczmq -lzmq
Cflags: -I${includedir}
So, if PKG_CONFIG_PATH is indeed the environment variable I need to set, how to I get pkg-config to actually use it? Or what else am I missing here? This is in Fedora 31, FWIW.
Apparently (judging by the very large version number), you're using some other implementation of pkg-config: namely, from this page I gather that it's something called pkgconf and is intended to somehow replace the FDO pkg-config program.
To succeed with PKG_CONFIG_PATH, I suppose, you should install a real pkg-config from FDO, whose version should be in the range of 0.29.x.

Compiling FileZilla on OSX

I've been trying to compile the FileZilla versions 3.11 and 3.24 on Mac for a research project but when I run ../configure I get the following error:
configure: error: libgnutls 3.1.12 greater was not found. You can get it from http://gnutls.org/
However, I've installed gnutls using homebrew; when I run
brew list gnutls
I can see the library installed at /usr/local/Cellar/gnutls/3.5.8/
Any ideas to resolve the problem are appreciated. Thanks
Updated Answer
It seems that GNUtls, as installed by homebrew ships with a pkgconfig file. So, you need to install pkgconfig if you don't have it already using:
brew install pkgconfig
Then, once you have that, you can find the compiler include file settings with:
pkg-config --cflags gnutls
Sample Output
-I/usr/local/Cellar/gnutls/3.5.8/include -I/usr/local/Cellar/nettle/3.3/include -I/usr/local/Cellar/libtasn1/4.10/include -I/usr/local/Cellar/p11-kit/0.23.3/include/p11-kit-1
And the linker library settings with:
pkg-config --libs gnutls
Sample Output
-L/usr/local/Cellar/gnutls/3.5.8/lib -lgnutls
So, we (just) need to convey that information to FileZilla. So, first we run:
./configure --help | grep -i utls
Sample Output
--enable-gnutlssystemciphers
Enables the use of gnutls system ciphers.
LIBGNUTLS_CFLAGS
C compiler flags for LIBGNUTLS, overriding pkg-config
LIBGNUTLS_LIBS
linker flags for LIBGNUTLS, overriding pkg-config
So it looks like we need to do something like:
export LIBGNUTLS_CFLAGS=$(pkg-config --cflags gnutls)
export LIBGNUTLS_LIBS=$(pkg-config --libs gnutls)
./configure
Original Answer
I haven't tried this with FileZilla, but I use it with other packages, and there is nothing to lose...
If homebrew has installed your GNUtls in /usr/local/Cellar/gnutls/3.5.8/, you could try telling FileZilla that location in your configure like this:
./configure CPPFLAGS="-I/usr/local/Cellar/gnutls/3.5.8/include" LDFLAGS="-L/usr/local/Cellar/gnutls/3.5.8/lib" ... other flags

Get cmake and home-brew to work together

When I install libraries with homebrew cmake can't seem to find them. Is there a simple way to fix this for an arbitrary library installed with brew.
Default
By default brew's libraries installed to /usr/local/lib folder:
> ls /usr/local/lib/liblzma.dylib
/usr/local/lib/liblzma.dylib#
Check that this path exists in CMAKE_SYSTEM_PREFIX_PATH variable. In this case
find is trivial:
message("system: ${CMAKE_SYSTEM_PREFIX_PATH}")
find_library(LZMA_LIBRARY lzma)
message("lzma: ${LZMA_LIBRARY}")
Result:
system: /usr/local;/usr;/;...
lzma: /usr/local/lib/liblzma.dylib
Otherwise
If it is not you need to modify CMAKE_PREFIX_PATH or CMAKE_LIBRARY_PATH
before find_library command:
list(APPEND CMAKE_PREFIX_PATH /usr/local)

pkg-config and OSX 10.8, proper PKG_CONFIG_PATH? Missing .pc files?

I installed pkg-config with homebrew in OSX. I'm not sure what I should set my PKG_CONFIG_PATH to? Should it be a combination of /usr/include and /usr/local/include? Even if I use one or the other, I get an error about there not being any .pc files, which I take it would contain info used by pkg-config? Not sure what I'm doing wrong. Help appreciated.
$ pkg-config --libs libxml2
Package libxml2 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libxml2.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libxml2' found
Update:
So maybe I'm asking two different questions. I just curled gsl and ran through the ./configure && make && sudo make install. And with an empty $PKG_CONFIG_PATH I actually got a hit with:
pkg-config --libs gsl
-L/usr/local/lib -lgsl -lgslcblas -lm
But listing /usr/local/lib shows the gsl libs but no .pc files. How come pkg-config works for custom installed packages in OSX but not default installed ones???
echo "export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/lib" >> ~/.bashrc && source ~/.bashrc
to test with say glib:
brew install glib && pkg-config --libs --cflags glib-2.0
should get you the goods:
-I/usr/local/Cellar/glib/2.34.3/include/glib-2.0 -I/usr/local/Cellar/glib/2.34.3/lib/glib-2.0/include -I/usr/local/Cellar/gettext/0.18.2/include -L/usr/local/Cellar/glib/2.34.3/lib -L/usr/local/Cellar/gettext/0.18.2/lib -lglib-2.0 -lintl
I can't add a clarification comment to Nick's answer above, but that is the correct set of paths you need, I have tried with success using homebrew on osx 10.9.1.
If you want this to work with a GUI application such as an IDE, you need to add that path to /etc/launchd.conf.
See the following stack overflow comment:
Setting environment variables in OS X?

Resources