2012-08-09 22 views
1

我試圖使用Linux安裝adns-python,不得不重新編譯adns一些特殊選項,所以我似乎無法使用easy_install <tarball>,因爲我通常會Python的easy_install的和自定義頁眉/庫的位置

(py26_default)[[email protected] src]$ easy_install adns-python-1.2.1.tar.gz 
Processing adns-python-1.2.1.tar.gz 
Running adns-python-1.2.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-9cVl4i/adns-python-1.2.1/egg-dist-tmp-vvO8Ms 
adnsmodule.c:10:18: error: adns.h: No such file or directory 
adnsmodule.c:31: error: expected specifier-qualifier-list before âadns_stateâ 

adns.h安裝在/opt/adns/include/adns.h之下;我如何使用本地安裝adns進行easy_install安裝?

編輯

下面的嘗試之後,我仍然覺得一個ld錯誤,即使我出口LD_LIBRARY_PATH ...

(py26_default)[[email protected] src]$ ls /opt/adns/lib/ 
libadns.a libadns.so libadns.so.1 libadns.so.1.2 
(py26_default)[[email protected] src]$ export LD_LIBRARY_PATH=/opt/adns/lib 
(py26_default)[[email protected] src]$ C_INCLUDE_PATH=/opt/adns/include easy_install ./adns-python-1.2.1.tar.gz 
Processing adns-python-1.2.1.tar.gz 
Running adns-python-1.2.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-x68T9f/adns-python-1.2.1/egg-dist-tmp-MpCzMP 
/usr/bin/ld: cannot find -ladns 
collect2: ld returned 1 exit status 
error: Setup script exited with error: command 'gcc' failed with exit status 1 
(py26_default)[[email protected] src]$ 

回答

3

LD_LIBRARY_PATH用於在運行時(運行可執行文件時)找到共享庫,而不是在鏈接過程中。

要構建擴展,解壓壓縮包,然後運行:

python setup.py build_ext -I/opt/adns/include -L/opt/adns/lib -R/opt/adns/lib 

要安裝:

python setup.py install 

你可以在setup.cfg指定build_ext選項:

[build_ext] 
include_dirs=/opt/adns/include 
library_dirs=/opt/adns/lib 
rpath=/opt/adns/lib 

在這種情況下,你可以直接運行easy_install 。

0

請嘗試這樣

INCLUDE_PATH=/opt/adns/include easy_install adns-python-1.2.1.tar.gz 

如果它不工作請試用CPLUS_INCLUDE_PATHC_INCLUDE_PATH

+0

這是什麼服務器?另請嘗試安裝完整的開發堆棧'build-essential'(for c)和'python-all-dev'(for python)。然後嘗試相同的命令。 – Pradeeshnarayan 2012-08-09 19:34:25

+0

由於'/ usr/bin/ld:無法找到-ladns',安裝失敗......在這一點上,它與python devel libs或c build tools無關 – 2012-08-09 19:35:38