Saturday, August 1, 2009

Setting environment variables in Mac OS X

I have suffered many times by the fact that applications from the dock or from the spotlight do not reach the same environment variables as if they were started from a shell. This is really problematic as some of them start non-interactive non-login sh shells (e.g. Doxygen, Eclipse plugins, etc) which cannot work properly without access to executables such as LaTeX, mercurial, etc.

I have tried many solutions, including the magical ~/.MacOSX/environment.plist, etc. Only one worked: I created a launchd.conf file in /etc and filled it up with content like:

setenv PATH /bin:/sbin:/usr/bin:/usr/sbin:/usr/libexec:/System/Library/CoreServ\
ices:/usr/texbin:/sw/bin:/usr/local/bin

After this all you need is a reboot.

Friday, June 12, 2009

Linking statically with Xerces C++ on Mac OS 10.5

Xerces C++ 3.01 automatically builds static and dynamic libraries as well. There are three things you will need to do in order to successfully link such a static library to your application:

- If you build Xerces-C++ with the network support (the default) then you will need to link to the curl library
- You need to specify the following g++ options: -Wl,-framework -Wl,CoreServices
- You need to add libxerces-c.a to the linker

Example:

g++ -Wl,-framework -Wl,CoreServices -o "DLog++" ./src/DLog++.o ./src/debug.o ./src/owl_parser.o /usr/local/lib/libxerces-c.a -lcurl


For the same thing under windows check this out: http://wiki.codesynthesis.com/Xerces_tips