python - 使用 google-perftools 编译 Python 2.7.2

标签 python compilation google-perftools

我有一个 debian squeeze 操作系统(64 位)。我想将 python 与 google-perftools 一起使用。为了执行此操作,我使用选项“-lctmalloc”编译了自己的 python 2.72。但我遇到了一些错误。

  1. 我安装了 libuwind,因为 google-perftool 在使用 64 位时需要此软件包
  2. 我安装了所需的所有软件包:

步骤:

> sudo apt-get -y install build-essential 
> sudo apt-get -y install zlib1g-dev libxml2-dev libxslt1-dev libssl-dev libncurses5-dev  
> sudo apt-get -y install libreadline6-dev autotools-dev autoconf automake libtool 
> sudo apt-get -y install libsvn-dev mercurial subversion git-core 
> sudo apt-get -y install libbz2-dev libgdbm-dev sqlite3 libsqlite3-dev 
> sudo apt-get -y install curl libcurl4-gnutls-dev 
> sudo apt-get -y install libevent-dev libev-dev librrd4 rrdtool 
> sudo apt-get -y install uuid-dev libdb4.8-dev memcached libmemcached-dev  
> sudo apt-get -y install libmysqlclient-dev libexpat1-dev 
> sudo apt-get -y install google-perftool 
> cd python 
> export CFLAGS='-ltcmalloc' 
> ./configure 
> make

这就是我得到的:

gcc  -Xlinker -export-dynamic -o python \
            Modules/python.o \
            libpython2.7.a -ldl  -lutil   -lm  
libpython2.7.a(posixmodule.o): In function `posix_tmpnam':
/home/toto/python272/Python-2.7.2/./Modules/posixmodule.c:7370: warning: the use of `tmpnam_r' is dangerous, better use `mkstemp'
libpython2.7.a(posixmodule.o): In function `posix_tempnam':
/home/toto/python272/Python-2.7.2/./Modules/posixmodule.c:7317: warning: the use of `tempnam' is dangerous, better use `mkstemp'
libpython2.7.a(thread.o): In function `_pythread_pthread_set_stacksize':
/home/toto/python272/Python-2.7.2/Python/thread_pthread.h:491: undefined reference to `pthread_attr_setstacksize'
libpython2.7.a(thread.o): In function `PyThread_release_lock':
/home/toto/python272/Python-2.7.2/Python/thread_pthread.h:346: undefined reference to `sem_post'
libpython2.7.a(thread.o): In function `PyThread_acquire_lock':
/home/toto/python272/Python-2.7.2/Python/thread_pthread.h:323: undefined reference to `sem_trywait'
/home/toto/python272/Python-2.7.2/Python/thread_pthread.h:321: undefined reference to `sem_wait'
libpython2.7.a(thread.o): In function `PyThread_free_lock':
/home/toto/python272/Python-2.7.2/Python/thread_pthread.h:292: undefined reference to `sem_destroy'
libpython2.7.a(thread.o): In function `PyThread_allocate_lock':
/home/toto/python272/Python-2.7.2/Python/thread_pthread.h:268: undefined reference to `sem_init'
libpython2.7.a(thread.o): In function `PyThread_start_new_thread':
/home/toto/python272/Python-2.7.2/Python/thread_pthread.h:183: undefined reference to `pthread_attr_setstacksize'
/home/toto/python272/Python-2.7.2/Python/thread_pthread.h:193: undefined reference to `pthread_create'
/home/toto/python272/Python-2.7.2/Python/thread_pthread.h:209: undefined reference to `pthread_detach'
libpython2.7.a(thread.o): In function `PyThread_acquire_lock':
/home/toto/python272/Python-2.7.2/Python/thread_pthread.h:321: undefined reference to `sem_wait'
libpython2.7.a(thread.o): In function `PyThread_release_lock':
/home/toto/python272/Python-2.7.2/Python/thread_pthread.h:346: undefined reference to `sem_post'
/home/toto/python272/Python-2.7.2/Python/thread_pthread.h:346: undefined reference to `sem_post'
/home/toto/python272/Python-2.7.2/Python/thread_pthread.h:346: undefined reference to `sem_post'
libpython2.7.a(thread.o): In function `PyThread_allocate_lock':
/home/toto/python272/Python-2.7.2/Python/thread_pthread.h:268: undefined reference to `sem_init'
/home/toto/python272/Python-2.7.2/Python/thread_pthread.h:268: undefined reference to `sem_init'
collect2: ld returned 1 exit status
make: *** [python] Error 1
You have new mail in /var/mail/root

当我在没有 CFLAGS='-ltcmalloc' 的情况下执行完全相同的操作时,我真的不明白这个错误,我能够编译。 感谢您的帮助。

最佳答案

使用LDFlags

-ltcmalloc

并且它需要 posix 线程支持。

-lpthread

关于python - 使用 google-perftools 编译 Python 2.7.2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8390095/

相关文章:

使用多个分隔符和非罗马字符分割Python字符串

python - 基于边缘像素图的图像分割

Java:仅编译另一个类中选定的方法

涉及Glib2库的C程序编译问题?

c - USB驱动编译错误

python - Tornado 请求处理程序

python - 遵循 Heroku Python 教程时的 TemplateSyntaxError

c++ - 为什么与 tcmalloc 链接会减少 500MB 的内存使用量?

go - Go程序中如何使用pprof

c++ - 为什么 tcmalloc 不打印通过 dlopen 提供的函数名称