<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ClearChain &#187; search paths</title>
	<atom:link href="http://www.clearchain.com/blog/tags/search-paths/feed" rel="self" type="application/rss+xml" />
	<link>http://www.clearchain.com/blog</link>
	<description>-= Daily Happenings =-</description>
	<lastBuildDate>Tue, 17 Aug 2010 06:21:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>jhbuild just won&#8217;t build! (aka Include path madness)</title>
		<link>http://www.clearchain.com/blog/posts/jhbuild-just-wont-build-aka-include-path-madness</link>
		<comments>http://www.clearchain.com/blog/posts/jhbuild-just-wont-build-aka-include-path-madness#comments</comments>
		<pubDate>Mon, 17 Nov 2008 23:42:04 +0000</pubDate>
		<dc:creator>Benjamin Close</dc:creator>
				<category><![CDATA[FreeDesktop]]></category>
		<category><![CDATA[OpenSource]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[UniSA]]></category>
		<category><![CDATA[C_INCLUDE_PATH]]></category>
		<category><![CDATA[gcc]]></category>
		<category><![CDATA[jhbuild]]></category>
		<category><![CDATA[search paths]]></category>

		<guid isPermaLink="false">http://www.clearchain.com/blog/?p=137</guid>
		<description><![CDATA[I&#8217;ve been recently trying to work out why jhbuild fails to build xorg on my FreeBSD box. Traditionally I compile to /usr/local/ however after wanting to experiment with MPX I&#8217;ve set things up so that I compile to /usr/local/MPX Sadly this kept breaking in xorg/lib/libX11 with the error: xcb_io.c: In function 'require_socket': xcb_io.c:35: warning: implicit declaration [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been recently trying to work out why jhbuild fails to build xorg on my FreeBSD box. Traditionally I compile to <em>/usr/local/</em> however after wanting to experiment with MPX I&#8217;ve set things up so that I compile to <em>/usr/local/MPX</em></p>
<p>Sadly this kept breaking in xorg/lib/libX11 with the error:</p>
<p><span id="more-137"></span></p>
<pre style="padding-left: 30px; ">xcb_io.c: In function 'require_socket':
xcb_io.c:35: warning: implicit declaration of function 'xcb_take_socket'
xcb_io.c:35: warning: nested extern declaration of 'xcb_take_socket'
xcb_io.c: In function 'process_responses':
xcb_io.c:188: error: 'GenericEvent' undeclared (first use in this function)
xcb_io.c:188: error: (Each undeclared identifier is reported only once
xcb_io.c:188: error: for each function it appears in.)
xcb_io.c:189: error: 'xcb_ge_event_t' undeclared (first use in this function)
xcb_io.c:189: error: expected expression before ')' token
xcb_io.c:193: error: expected expression before ')' token
xcb_io.c: In function '_XSend':
xcb_io.c:332: warning: implicit declaration of function 'xcb_writev'
xcb_io.c:332: warning: nested extern declaration of 'xcb_writev'</pre>
<p> </p>
<p>For the life of me I couldn&#8217;t make sense of it. GenericEvent is defined in xcb/xcb.h and checking the preprocessor output xcb.h was being included. Likewise the lack of xcb_ge_event_t was baffling me as it was certain in xcb/xcb.h. It wasn&#8217;t till I looked a little closer that I realised that the wrong xcb.h was being used. Turns out that /<em>usr/local/include/xcb/xcb.h</em> was being used however I wanted <em>/usr/local/MPX/include/xcb/xcb.h</em> to be used. Hence I tried adding <em>-I/usr/local/MPX</em> to CFLAGS with no success and also tried setting <em>CC=&#8221;gcc -I/usr/local/MPX&#8221;</em> also with no success. It just didn&#8217;t make sense!</p>
<p>Looking at the gcc line, <em>/u</em><em>sr/local/MPX</em> should have been used first. It wasn&#8217;t until I finally check the preprocessor what it thought the system paths were did it all make sense.</p>
<p>The output from cpp is below:</p>
<pre style="padding-left: 30px; "><span style="font-family: 'Lucida Grande'; line-height: 19px; white-space: normal; ">U</span>sing built-in specs.
Target: amd64-undermydesk-freebsd
Configured with: FreeBSD/amd64 system compiler
Thread model: posix
gcc version 4.2.1 20070719  [FreeBSD]
 /usr/libexec/cc1 -E -quiet -v -I. -I../include/X11 -I../include -I../include/X11
-I../include -I../include/X11 -I../src/xcms -I../src/xkb -I../src/xlibi18n -I/usr/local/include 
-D_LONGLONG -DHAVE_CONFIG_H -D_BSD_SOURCE -DHAS_FCHOWN -DHAS_STICKY_DIR_BIT -D_THREAD_SAFE -D_BSD_SOURCE
-DX11_t -DTRANS_CLIENT -isystem /usr/local/MPX/include xcb_io.c -o xcb_io.lo -Wall -Wpointer-arith
-Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -fno-strict-aliasing -fworking-directory -O0</pre>
<pre style="padding-left: 30px; ">ignoring duplicate directory "/usr/local/MPX/include"
ignoring duplicate directory "/usr/include"
ignoring duplicate directory "../include/X11"
ignoring duplicate directory "../include"
ignoring duplicate directory "../include/X11"
#include "..." search starts here:
#include &lt;...&gt; search starts here:
 .
 ../include/X11
 ../include
 ../src/xcms
 ../src/xkb
 ../src/xlibi18n
 /usr/local/include
 /usr/local/MPX/include
 /usr/include
End of search list.</pre>
<p>It turns out that jhbuild sets the environment variable <em>C_INCLUDE_PATH, </em>in this case to <em>/usr/local/MPX/include</em>. This variable adds a library to the system search path. Whilst it prepends to the system search path,  -I<em> </em>options prepend the system search path, hence with one -I option being <em>/usr/local/include</em>, we get the ordering incorrect and the wrong header is used.  </p>
<p>So now it was up to working out why <em>/usr/local/include</em> was needed. Searching config.log it turns out the bigfontproto was needed by libX11, pkg_config was searching for it and finding it not in <em>/usr/local/MPX/lib/share/pkg_config</em> but in <em>/usr/local/lib/share/pkg_config</em>. The reason for this is bigfontproto wasn&#8217;t listed as a dependancy in the xorg.modules file used by jhbuild (avaliable at:<a href="http://cgit.freedesktop.org/xorg/util/modular/tree/xorg.modules">http://cgit.freedesktop.org/xorg/util/modular/tree/xorg.modules</a>). Because of this bigfont proto wasn&#8217;t being built by <a href="http://www.jamesh.id.au/software/jhbuild/">jhbuild</a>. Hence the only bigfontproto that existed on the box was the default system bigfont proto which WAS located under /usr/local/include. </p>
<p>The fix was simple. List xf86bigfontproto as a dependency in xorg.modules and all was good. bigfontproto is now pulled in as a dependency and hence gets built before libX11. pkg_config now correctly finds bigfontproto in /<em>usr/local/MPX/lib/share/pkg_config</em> hence doesn&#8217;t need to fallback to the system version so <em>-I/usr/local/include</em> doesn&#8217;t get added to the gcc line. Hence the compiler uses <em>/usr/local/MPX/include/xcb/xcb.h </em>rather than the one in <em>/usr/local/include/xcb/xcb.h</em> and the compiler errors vanish.</p>
<p>So now things are building and I&#8217;m off for a coffee!<br />
(xorg.modules has also been correctly updated so some other poor person doesn&#8217;t have the same issues).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.clearchain.com/blog/posts/jhbuild-just-wont-build-aka-include-path-madness/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
