8

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 ファイルを作成しますが、機能しません。例のように 2.1 ではなく python2.5 を使用していますが、これは問題ですか? エラー (その他はすべて「警告」です) は、プラットフォームが間違っていることを示しています。これは 64 ビット マシンです。これは問題ですか?gcc の構成がマシンに対して間違っていますか? どうすればこれを乗り越えることができますか?

更新: まだ問題があります。この「修正」を実際に実装するにはどうすればよいですか?

4

3 に答える 3

7

このスレッドは、64ビットcentosに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
于 2010-05-25T22:36:08.050 に答える
2

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

あなたが示唆しているように、アレックス、私のマシンの要件とインストールしたいパッケージの要件に一致するように、正しいバージョンの Python の epd をインストールする必要がありました。Python の並行バージョンが実行されていましたが、これが混乱とエラーの原因だと思います。Enthought のリポジトリに移動し([リポジトリにログイン] -> [インストーラ] をクリック)、正しいバージョンをインストールします。

古いバージョンの Python を削除して、クリーンアップを行ってください (または、何をしているのかを知っている人に依頼してください)。それからもちろん、.cshrc パスを新しいバージョンを指すように変更し、ファイルを正しくソースします。これを行った後、問題はありませんでした。

この質問が 4 年前に出されたことに気づきました。

于 2013-07-30T22:09:36.083 に答える
2

libxml2ソースからインストールしようとしているときに、実際にこのスレッドを2回、数年離れて見つけました。ライブラリのconfigureスクリプトには実際に--without-pythonオプションがあり、エラーを修正する代わりに使用しました。

于 2013-10-29T20:25:24.287 に答える