簡體   English   中英

一個簡單的Python SWIG錯誤問題

[英]A trivial Python SWIG error question

我試圖讓Python運行swig來做C / C ++。 我在這里運行教程,'構建一個python模塊'。 當我打電話的時候

gcc -c example.c example_wrap.c -I /my_correct_path/python2.5

我收到一個錯誤:

my_correct_path/python2.5/pyport.h:761:2: error: #error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)."
example_wrap.c: In function 'SWIG_Python_ConvertFunctionPtr':
example_wrap.c:2034: warning: initialization discards qualifiers from pointer target type
example_wrap.c: In function 'SWIG_Python_FixMethods':
example_wrap.c:3232: warning: initialization discards qualifiers from pointer target type

它確實創建了一個example.o文件,但它不起作用。 我在使用python2.5而不是2.1,例如,這是一個問題嗎? 錯誤(其他一切只是一個'警告')說錯誤的平台。 這是一台64位的機器; 這是一個問題嗎? 我的gcc配置錯誤了嗎? 我如何通過這個?

更新:我還有問題。 我如何實際實現這個“修復”?

我發現這個線程正在尋找一個答案,同時為64位的32位python安裝python readline時出現相同的“LONGBIT”錯誤。 該鏈接沒有直接的答案,所以我不得不進一步谷歌答案(對於經驗豐富的Linux用戶/開發者來說可能是直截了當的)。 為了將來參考,解決方案是在CFLAGS環境變量中使用“-m32”強制32位。

bash-3.2$ easy_install readline
Searching for readline
Reading http://pypi.python.org/simple/readline/
Reading http://www.python.org/
Best match: readline 2.6.4
Downloading http://pypi.python.org/packages/source/r/readline/readline-2.6.4.tar.gz#md5=7568e8b78f383443ba57c9afec6f4285
Processing readline-2.6.4.tar.gz
Running readline-2.6.4/setup.py -q bdist_egg --dist-dir /tmp/easy_install-mqr9wH/readline-2.6.4/egg-dist-tmp-p3apfF
In file included from /usr/local/python2.6/include/python2.6/Python.h:58,
                 from Modules/readline.c:8:
/usr/local/python2.6/include/python2.6/pyport.h:685:2: error: #error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)."
error: Setup script exited with error: command 'gcc' failed with exit status 1

然后我嘗試使用CFLAGS = -m32:

bash-3.2$ CFLAGS=-m32 easy_install readline
Searching for readline
Reading http://pypi.python.org/simple/readline/
Reading http://www.python.org/
Best match: readline 2.6.4
Downloading http://pypi.python.org/packages/source/r/readline/readline-2.6.4.tar.gz#md5=7568e8b78f383443ba57c9afec6f4285
Processing readline-2.6.4.tar.gz
Running readline-2.6.4/setup.py -q bdist_egg --dist-dir /tmp/easy_install-uauVci/readline-2.6.4/egg-dist-tmp-YY0tQa
In file included from /usr/include/features.h:352,
                 from /usr/include/limits.h:27,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.1.2/include/limits.h:122,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.1.2/include/syslimits.h:7,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.1.2/include/limits.h:11,
                 from /usr/local/python2.6/include/python2.6/Python.h:19,
                 from Modules/readline.c:8:
/usr/include/gnu/stubs.h:7:27: error: gnu/stubs-32.h: No such file or directory
error: Setup script exited with error: command 'gcc' failed with exit status 1

最新的錯誤是由於沒有32位的glibc-devel包(感謝這個線程 )。 我還必須安裝ncurses-devel.i386然后easy_install經過並且ipython認出了它。 我的生活感到毀了,直到我為了ipython而工作。

bash-3.2$ CFLAGS=-m32 easy_install readline
Searching for readline
Reading http://pypi.python.org/simple/readline/
Reading http://www.python.org/
Best match: readline 2.6.4
Downloading http://pypi.python.org/packages/source/r/readline/readline-2.6.4.tar.gz#md5=7568e8b78f383443ba57c9afec6f4285
Processing readline-2.6.4.tar.gz
Running readline-2.6.4/setup.py -q bdist_egg --dist-dir /tmp/easy_install-dHly4D/readline-2.6.4/egg-dist-tmp-oIEDYl
Adding readline 2.6.4 to easy-install.pth file

Installed /home/hari/bin/python/lib/python2.6/site-packages/readline-2.6.4-py2.6-linux-x86_64.egg
Processing dependencies for readline
Finished processing dependencies for readline

我在嘗試安裝Python包時遇到了同樣的錯誤,但修復了它。
“LONG_BIT”錯誤是:

$ easy_install astropy  
/my_path/epd/epd-7.3-2-rh5-x86/include/python2.7/pyport.h:849:2: 
error: #error "LONG_BIT definition appears wrong for platform 
(bad gcc/glibc config?)." error: Setup script exited with error: 
command 'gcc' failed with exit status 1

正如你所建議的那樣,Alex,我必須安裝正確版本的Python的epd才能滿足我的機器要求和我想要安裝的軟件包的要求。 有並行版本的Python運行,我認為這是混亂和錯誤的來源。 轉到Enthought的存儲庫 (單擊“登錄存儲庫” - >安裝程序)並安裝正確的版本。

通過刪除舊的Python版本,確保清理(或詢問知道他們正在做什么的人為你做這件事)。 然后當然更改.cshrc路徑以指向新版本並正確地獲取文件。 我這樣做后沒有問題。

我意識到這個問題是在4年前被問到的!

實際上,在嘗試從源代碼安裝libxml2 ,我發現這個線程兩次,相隔幾年。 庫的configure腳本實際上有一個--without-python選項,我使用它而不是試圖修復錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM