Problem with compiling ganglia from source - expat.h not found

I'm trying to compile ganglia from source. Compilation aborts with the following error
Code:
ganglia.c:8:19: error: expat.h: No such file or directory
ganglia.c: In function 'gexec_cluster':
ganglia.c:255: error: 'XML_Parser' undeclared (first use in this function)
ganglia.c:255: error: (Each undeclared identifier is reported only once
ganglia.c:255: error: for each function it appears in.)
ganglia.c:255: error: expected ';' before 'xml_parser'
ganglia.c:276: error: 'xml_parser' undeclared (first use in this function)
ganglia.c:276: warning: implicit declaration of function 'XML_ParserCreate'
ganglia.c:288: warning: implicit declaration of function 'XML_SetElementHandler'
ganglia.c:289: warning: implicit declaration of function 'XML_SetUserData'
ganglia.c:294: warning: implicit declaration of function 'XML_GetBuffer'
ganglia.c:294: warning: initialization makes pointer from integer without a cast
ganglia.c:312: warning: implicit declaration of function 'XML_ParseBuffer'
ganglia.c:316: warning: implicit declaration of function 'XML_GetCurrentLineNumber'
ganglia.c:317: warning: implicit declaration of function 'XML_ErrorString'
ganglia.c:317: warning: implicit declaration of function 'XML_GetErrorCode'
ganglia.c:317: warning: format '%s' expects type 'char *', but argument 3 has type 'int'
ganglia.c:336: warning: implicit declaration of function 'XML_ParserFree'
*** Error code 1

But expat.h exists:
Code:
[/dev/pts/6]root@testhost:~# locate expat.h
/usr/local/include/expat.h
/usr/local/include/python2.7/pyexpat.h
/usr/src/contrib/expat/lib/expat.h

Also I tried to install textproc/expat2, however it didn't help.
 
C compilers on FreeBSD do not search /usr/local/include for include files by default. This is for an obvious reason to keep the base system separate from the ports. You have to add a -I /usr/local/include flag to the compiler flags yourself. Or consider letting the ports(7) infrastructure to do the hard work for you.


FreeBSD Porter's Handbook
 
Besides the aforementioned -I you usually also need to tell it where the libraries are with -L /usr/local/lib.
 
You have to add a -I /usr/local/include flag to the compiler flags yourself. Or consider letting the ports(7) infrastructure to do the hard work for you.
make -I /usr/local/include didn't solve my problem. However it compiled successfully after I had created symlinks of expat.h, expat_external.h and confuse.h in /usr/include
 
Please don't make such symlinks, the /usr/include directory should be left only for the base OS includes. What I meant is that you should add -I /usr/local/include to the CFLAGS make variable.
 
The CFLAGS variable in my Makefile looks like this:
Code:
CFLAGS = -pthread -g -O2 -fno-strict-aliasing -Wall -D_REENTRANT

I amended Makefile to make it look like this:
Code:
CFLAGS = -pthread -g -O2 -fno-strict-aliasing -Wall -D_REENTRANT -I/usr/local/include

It didn't work for me. Then I supplied it as argument: make CFLAGS="-pthread -g -O2 -fno-strict-aliasing -Wall -D_REENTRANT -I/usr/local/include" and it compiled without errors. Could you advise why the first variant didn't work?
 
Back
Top