I'm a new user of xtrkcad and am using it on FreeBSD. I was able to get it to compile using the instructions in the exchange in this email: http://groups.yahoo.com/group/XTrkCad/message/5599
I've generalized the suggested solutions in those emails - included the attached patch (against 4.2.0 beta 1, but I can rework it against the Mercurial version, if that would help). It successfully builds on FreeBSD, but I don't have other systems to test it on to ensure I haven't broken anything with it.
Hope this helps and thanks for a great program..