Opened 6 years ago

Last modified 5 years ago

#57990 reopened defect

libxml2 @2.9.7_2: ICU include directory not in pkg-config output — at Version 4

Reported by: dsedivec Owned by:
Priority: Normal Milestone:
Component: ports Version: 2.5.4
Keywords: Cc: raimue (Rainer Müller), MarcusCalhoun-Lopez (Marcus Calhoun-Lopez), ryandesign (Ryan Carsten Schmidt)
Port: libxml2

Description (last modified by ryandesign (Ryan Carsten Schmidt))

Since libxml2 now builds against ICU, I cannot build software against MacPorts libxml2 without manually including -I$prefix/include when building. Quick example:

$ command -v pkg-config
/opt/local/bin/pkg-config

$ cat repro.c
/* Include inspired by PostGIS's configure script: */
#include <libxml/tree.h>

int main() { return 0; }

$ clang $(pkg-config --cflags libxml-2.0) repro.c $(pkg-config --libs libxml-2.0)
In file included from repro.c:2:
In file included from /opt/local/include/libxml2/libxml/tree.h:1307:
In file included from /opt/local/include/libxml2/libxml/xmlmemory.h:218:
In file included from /opt/local/include/libxml2/libxml/threads.h:35:
In file included from /opt/local/include/libxml2/libxml/globals.h:18:
In file included from /opt/local/include/libxml2/libxml/parser.h:810:
/opt/local/include/libxml2/libxml/encoding.h:31:10: fatal error: 'unicode/ucnv.h' file not found
#include <unicode/ucnv.h>
         ^~~~~~~~~~~~~~~~
1 error generated.

$ clang -I/opt/local/include $(pkg-config --cflags libxml-2.0) repro.c $(pkg-config --libs libxml-2.0)

$ ls a.out
a.out*

After a brief conversation on IRC it was requested that I open a ticket for this, since the ICU cflags/libs flags should probably be included in pkg-config output for libxml-2.0 now. (It was also suggested that maybe this is really an upstream issue, rather than MacPorts.)

Change History (4)

comment:1 Changed 6 years ago by mf2k (Frank Schima)

Cc: MarcusCalhoun-Lopez added

Cc'ing committer of that change for possible comment.

comment:2 Changed 6 years ago by kencu (Ken)

Hi -- it would be most helpful if you could include your main.log and your configure.log files as well (please attach them to this ticket.

I get this:

checking for ICU... yes
Enabled Schemas/Relax-NG support
checking for printf... yes
checking for sprintf... yes

and the port builds right through to the end with icu support enabled.

So it's likely to be something on your system somewhere that is messing you up. The usual culprits are homebrew and anything you have installed in /usr/local.

comment:3 Changed 6 years ago by raimue (Rainer Müller)

This is not about building in MacPorts (therefore no main.log required), because with MacPorts ${prefix}/include would always be in the include path and this bug will not occur. This is about using libxml2 to compile software outside of MacPorts. The CFLAGS provided by pkg-config are insufficient as the libxml/*.h headers will try to include unicode/*.h and therefore the path to these headers also needs to be added to the pkg-config file.

comment:4 Changed 6 years ago by ryandesign (Ryan Carsten Schmidt)

Cc: ryandesign added
Description: modified (diff)

And just blindly adding -I${prefix}/include to libxml2's pkgconfig file can have other consequences. See how I fixed this issue for glib2 by patching glib2's header to #include the absolute path of the non-glib2 header it was requiring. I suggest doing something similar for libxml2: patching encoding.h so that it #includes the absolute path of ucnv.h.

Note: See TracTickets for help on using tickets.