You are here: Home Tech Compile Python-2.7 on FreeBSD

Compile Python-2.7 on FreeBSD

by Chris Shenton last modified Mar 24, 2011 10:53 AM
Need to patch in order to fix problem with ${LDFLAGS}. Don't use --enable-shared.

Python-2.7 and 2.7.1 encounter problems trying to compile code:

chris@Boqueria:coverage-3.4$ /usr/local/python/2.7/bin/python build_ext
running build_ext
building 'coverage.tracer' extension
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/local/python/2.7/include/python2.7 -\
c coverage/tracer.c -o build/temp.freebsd-7.2-STABLE-amd64-2.7/coverage/tracer.o
gcc -pthread -shared ${LDFLAGS} build/temp.freebsd-7.2-STABLE-amd64-2.7/coverage/tracer.o -lpython2.7 -o build/lib.freebsd-7.2-STABLE-amd64-\
gcc: ${LDFLAGS}: No such file or directory
error: command 'gcc' failed with exit status 1

This manifests itself in higher-level 'easy_install' and 'pip' usage but with less helpful diagnostic messages and it took me a while to isolate. 

Reed found this patch which was created shortly after python-2.7.1 was released:

It must be applied before compiling Python.

I found that if I used the --enable-shared flag, that when I invoked python, it couldn't find its libraries, so I don't use this.  My incantation is:

./configure --prefix=/usr/local/python/2.7.1 --enable-ipv6


Share this: