Lomadee, uma nova espécie na web. A maior plataforma de afiliados da América Latina.

sábado, agosto 14, 2010

Getting GCC working on Mac OS X

If for some reason you tried to build any source software package on Mac OS X and it failed with complains for headers, libraries of that C compiler (GCC) can't build binaries, it's very simple to get it working like you used to do in any GNU/Linux or Unix flavors. If you project are compatible with Xcode, just skip all this ;)

To put GCC to build things on Mac OS X, simple prefix (or export) the PATH, CFLAGS, LDFLAGS and CPPFLAGS to any configure script or make execution like show bellow:

For configure script
PATH=${PATH}:/Developer/usr/bin CFLAGS=-I/Developer/SDKs/MacOSX10.6.sdk/usr/include/ LDFLAGS=-L/Developer/SDKs/MacOSX10.6.sdk/usr/lib CPPFLAGS=-I/Developer/SDKs/MacOSX10.6.sdk/usr/include/ ./configure

For make
PATH=${PATH}:/Developer/usr/bin CFLAGS=-I/Developer/SDKs/MacOSX10.6.sdk/usr/include/ LDFLAGS=-L/Developer/SDKs/MacOSX10.6.sdk/usr/lib CPPFLAGS=-I/Developer/SDKs/MacOSX10.6.sdk/usr/include/ ./configure

You can add more includes or libraries paths by adding :-I or :-L to CFLAGS, CPPFLAGS and LDFLAGS environment variables, like:

CFLAGS=-I/Developer/SDKs/MacOSX10.6.sdk/usr/include:-I/Developer/usr/include

CPPFLAGS=-I/Developer/SDKs/MacOSX10.6.sdk/usr/include:-I/Developer/usr/include

LDFLAGS=-L/Developer/SDKs/MacOSX10.6.sdk/usr/lib:-L/Developer/usr/lib

That's all! Happy hacking...

Nenhum comentário: