2011-01-21 20 views
1

私はすでにこの質問を投稿者websiteに投稿しましたが、私はここでも尋ねるかもしれないと思いました。pylzma(lzma python binding)のインストール/コンパイル

私は、このセットアップでpylzmaをインストールしようとしてきた:

  • のWindows Server 2003 SDKから
  • 来るAMD64のコンパイラは、クローン化されたWindows 7のx64の
  • のPython 2.6.6のx64
  • Gitのレポのgit://github.com/fancycode/pylzma.git

シンプルeasy_install pylzmaでは、私はこれを得た:

cl : Command line warning D9025 : overriding '/MD' with '/MT' pylzma.c src/pylzma/pylzma.c(85) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data

src/pylzma/pylzma.c(102) : error C2275: 'CSha256' : illegal use of this type as an expression c:\users\xavier.lapointe\appdata\local\temp\easy_install-2mfkqu\pylzma-0.4.3\src\pylzma../7zip/C/Sha256.h(18) : see declaration of 'CSha256'

src/pylzma/pylzma.c(102) : error C2146: syntax error : missing ';' before identifier 'sha'

src/pylzma/pylzma.c(102) : error C2065: 'sha' : undeclared identifier

src/pylzma/pylzma.c(103) : error C2065: 'sha' : undeclared identifier

src/pylzma/pylzma.c(103) : warning C4133: 'function' : incompatible types - from 'int *' to 'CSha256 *'

src/pylzma/pylzma.c(104) : error C2143: syntax error : missing ';' before 'type'

src/pylzma/pylzma.c(105) : error C2143: syntax error : missing ';' before 'type'

src/pylzma/pylzma.c(106) : error C2143: syntax error : missing ';' before 'type'

src/pylzma/pylzma.c(107) : error C2143: syntax error : missing ';' before 'type'

src/pylzma/pylzma.c(108) : error C2065: 'round' : undeclared identifier

src/pylzma/pylzma.c(108) : error C2065: 'round' : undeclared identifier

src/pylzma/pylzma.c(108) : error C2065: 'rounds' : undeclared identifier

src/pylzma/pylzma.c(108) : error C2065: 'round' : undeclared identifier

src/pylzma/pylzma.c(109) : error C2065: 'sha' : undeclared identifier

src/pylzma/pylzma.c(109) : warning C4133: 'function' : incompatible types - from 'int *' to 'CSha256 *'

src/pylzma/pylzma.c(110) : error C2065: 'sha' : undeclared identifier

src/pylzma/pylzma.c(110) : warning C4133: 'function' : incompatible types - from 'int *' to 'CSha256 *'

src/pylzma/pylzma.c(111) : error C2065: 'sha' : undeclared identifier

src/pylzma/pylzma.c(111) : warning C4133: 'function' : incompatible types - from 'int *' to 'CSha256 *'

src/pylzma/pylzma.c(111) : error C2065: 'temp' : undeclared identifier

src/pylzma/pylzma.c(112) : error C2065: 'i' : undeclared identifier

src/pylzma/pylzma.c(112) : error C2065: 'i' : undeclared identifier

src/pylzma/pylzma.c(112) : error C2065: 'i' : undeclared identifier

src/pylzma/pylzma.c(113) : error C2065: 'temp' : undeclared identifier

src/pylzma/pylzma.c(113) : error C2065: 'i' : undeclared identifier

src/pylzma/pylzma.c(113) : error C2109: subscript requires array or pointer type

src/pylzma/pylzma.c(116) : error C2065: 'sha' : undeclared identifier

src/pylzma/pylzma.c(116) : warning C4133: 'function' : incompatible types - from 'int *' to 'CSha256 *'

error: Setup script exited with error: command '"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\amd64\cl.exe"' failed with exit status 2

は、その後、私はそれがコンパイラ(C99対C90)についてでした考え出しグーグルの後、何人かの人々が.CPPする.C拡張子を変更することが示唆されました。だから私はこれを行い、それに応じて(ほとんどのファイル名)setup.pyを変更しました。

それから、CpuArch.c(pp)と構文エラーがあった別のファイルで少し成功した後でコンパイルされます。

C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\amd64\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:C:\dev\pylzma\build\temp.win-amd64-2.6\Release\src\pylzma /LIBPATH:C:\Python26\libs /LIBPATH:C:\Python26\PCbuild\amd64 user32.lib oleaut32.lib /EXPORT:initpylzma build\temp.win-amd64-2.6\Release\src/pylzma/pylzma.obj build\temp.win-amd64-2.6\Release\src/pylzma/pylzma_decompressobj.obj build\temp.win-amd64-2.6\Release\src/pylzma/pylzma_compressfile.obj build\temp.win-amd64-2.6\Release\src/pylzma/pylzma_decompress.obj build\temp.win-amd64-2.6\Release\src/pylzma/pylzma_compress.obj build\temp.win-amd64-2.6\Release\src/pylzma/pylzma_streams.obj build\temp.win-amd64-2.6\Release\src/pylzma/pylzma_aes.obj build\temp.win-amd64-2.6\Release\src/pylzma/pylzma_decompress_compat.obj build\temp.win-amd64-2.6\Release\src/pylzma/pylzma_decompressobj_compat.obj build\temp.win-amd64-2.6\Release\src\sdk\LzFind.obj build\temp.win-amd64-2.6\Release\src\sdk\LzmaDec.obj build\temp.win-amd64-2.6\Release\src\sdk\LzmaEnc.obj build\temp.win-amd64-2.6\Release\src\7zip\C\CpuArch.obj build\temp.win-amd64-2.6\Release\src\7zip\C\Aes.obj build\temp.win-amd64-2.6\Release\src\7zip\C\AesOpt.obj build\temp.win-amd64-2.6\Release\src\7zip\C\Sha256.obj build\temp.win-amd64-2.6\Release\src\compat\LzmaCompatDecode.obj build\temp.win-amd64-2.6\Release\src/sdk/LzFindMt.obj build\temp.win-amd64-2.6\Release\src/sdk/Threads.obj /OUT:build\lib.win-amd64-2.6\pylzma.pyd /IMPLIB:build\temp.win-amd64-2.6\Release\src/pylzma\pylzma.lib /MANIFESTFILE:build\temp.win-amd64-2.6\Release\src/pylzma\pylzma.pyd.manifest

pylzma.obj : warning LNK4197: export 'initpylzma' specified multiple times; using first specification Creating library build\temp.win-amd64-2.6\Release\src/pylzma\pylzma.lib and object build\temp.win-amd64-2.6\Release\src/pylzma\pylzma.exp

pylzma.obj : error LNK2001: unresolved external symbol "char const * const doc_decompress" ([email protected]@3QBDB)

pylzma.obj : error LNK2001: unresolved external symbol "struct _object * __cdecl pylzma_decompress(struct _object *,struct _object *)" ([email protected]@[email protected]@[email protected]@Z)

pylzma.obj : error LNK2001: unresolved external symbol "char const * const doc_compress" ([email protected]@3QBDB)

Aes.obj : error LNK2019: unresolved external symbol "void __cdecl AesCtr_Code_Intel(unsigned int *,unsigned char *,unsigned __int64)" (?AesCt[email protected]@[email protected]) referenced in function AesGenTables

Aes.obj : error LNK2019: unresolved external symbol "void __cdecl AesCbc_Decode_Intel(unsigned int *,unsigned char *,unsigned __int64)" ([email protected]@[email protected]) referenced in function AesGenTables

Aes.obj : error LNK2019: unresolved external symbol "void __cdecl AesCbc_Encode_Intel(unsigned int *,unsigned char *,unsigned __int64)" ([email protected]@[email protected]) referenced in function AesGenTables

AesOpt.obj : error LNK2019: unresolved external symbol _mm_aesenclast_si128 referenced in function "void __cdecl AesCbc_Encode_Intel(union __m128i *,union __m128i *,unsigned __int64)" ([email protected]@[email protected]@[email protected])

AesOpt.obj : error LNK2019: unresolved external symbol _mm_aesenc_si128 referenced in function "void __cdecl AesCbc_Encode_Intel(union __m128i *,union __m128i *,unsigned __int64)" ([email protected]@[email protected]@[email protected])

AesOpt.obj : error LNK2019: unresolved external symbol _mm_aesdeclast_si128 referenced in function "void __cdecl AesCbc_Decode_Intel(union __m128i *,union __m128i *,unsigned __int64)" ([email protected]@[email protected]@[email protected])

AesOpt.obj : error LNK2019: unresolved external symbol _mm_aesdec_si128 referenced in function "void __cdecl AesCbc_Decode_Intel(union __m128i *,union __m128i *,unsigned __int64)" ([email protected]@[email protected]@[email protected]) build\lib.win-amd64-2.6\pylzma.pyd : fatal error LNK1120: 10 unresolved externals

error: command '"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\amd64\link.exe"' failed with exit status 1120

は、今私は(リンカーエラーについて)も、MSDNのドキュメントで、これらのリンカーの問題が何であるかを把握しよう苦労をしました:

事は今リンカチョークです。おそらく私のC/C++に関する知識が不足しているためです。

だから、基本的に私の質問(複数可)は次のとおりです。

  • これらのリンカーの問題を修正する方法はありますか?
  • これらのファイルの名前を.cから.cppに変更するのは間違っていますか?はいの場合は、msvc amd64コンパイラで.cとしてコンパイルすることは可能ですか?

EDIT は多くの答えを持っていない持っているので、私はいくつかの質問を追加すると思う:

  • それがエラーをリンカに来るとき、あなたのアプローチは何ですか?

  • ウェブで回答を見つけるのに役立つロジックはありますか(これはMSDN linker errorsと組み合わされます)?

  • 私は多くの人が32ビットシステムでうまくコンパイルするのを見てきましたので、64ビットでうまくコンパイルできますが、アーキテクチャタイプのためにリンクすると失敗する可能性がありますか?

私は、完全に機能する回答よりも役立つヒントを探しています。あなたの助けのための

どうもありがとうございました(:。

+0

minGWで構築しようとしましたか? – Velociraptors

+0

ファイル名の拡張子を.cppに変更した場合、関数プロトタイプが 'extern" C "{...}"ブロックであることを保証しているので、名前が変更されません。 –

+0

@Velociraptors 64ビットでコンパイルできますか? @Jack Kellyリンカのエラーに基づいてコードの一部をexternしようとしましたが、すべてをチェックしていませんでした(すぐにテストします) – Xavier

答えて

2

私は自分自身を、これを試してみるpylzmaをインストールしているのpython 2.6の場合には、mingwの罰金構築しますが、MSVCコンパイラがpython2.4-2.7用チョーク。のは、最初のエラーを見てみましょう:質問で

src/pylzma/pylzma.c(102) : error C2275: 'CSha256' : illegal use of this type as an expression c:\users\xavier.lapointe\appdata\local\temp\easy_install-2mfkqu\pylzma-0.4.3\src\pylzma../7zip/C/Sha256.h(18) : see declaration of 'CSha256'

コードは次のようになります。コードの後に​​変数を宣言することが許可されていませんので、はっきり無効Cである

} else { 
    Py_BEGIN_ALLOW_THREADS 
    Sha256_Init(&sha); 
    CSha256 sha; 
    long round; 
    int i; 
    long rounds = (long) 1 << cycles; 
    unsigned char temp[8] = { 0,0,0,0,0,0,0,0 }; 
    for (round = 0; round < rounds; round++) { 

。 .cppの名前を.cppに変更すると、C++はこれを許可しているので、このエラーを回避できます(そして、mingwはこれをC言語でサポートしています)。しかし、C++に切り替えると、名前の変更やリンクのエラーが発生しました。それらを修正するには、extern "C" { ... }をすべてのコードの周りに置くことができます。

これは、SRC/pylzma/pylzma.c htoughを修正する方が良いでしょうし、修正は簡単です - Py_BEGIN_ALLOW_THREADSとSha256_Init(& SHA)を移動します。変数宣言の後:

} else { 
    CSha256 sha; 
    long round; 
    int i; 
    long rounds = (long) 1 << cycles; 
    unsigned char temp[8] = { 0,0,0,0,0,0,0,0 }; 
    Py_BEGIN_ALLOW_THREADS 
    Sha256_Init(&sha); 
    for (round = 0; round < rounds; round++) { 

今pylzmaは罰金コンパイルが、リンク後のマニフェストツールを実行するために失敗します。ビルドディレクトリで探し

Creating library build\temp.win-amd64-2.6\Release\src/pylzma\pylzma.lib and o bject build\temp.win-amd64-2.6\Release\src/pylzma\pylzma.exp C:\Program Files\Microsoft SDKs\Windows\v7.0\bin\x64\mt.exe -nologo -manifest bu ild\temp.win-amd64-2.6\Release\src/pylzma\pylzma.pyd.manifest -outputresource:bu ild\lib.win-amd64-2.6\pylzma.pyd;2

build\temp.win-amd64-2.6\Release\src/pylzma\pylzma.pyd.manifest : general error c1010070: Failed to load and parse the manifest. The system cannot find the file specified. error: command 'mt.exe' failed with exit status 31

は、それがから見ていても何のpylzma.pyd.manifestが存在しないことが明らかになりましたlink.exeには/ MANIFEST:...スイッチがあります。 "リンクはマニフェストを作成しませんでした"のためのクイックグーグル検索はhttp://bugs.python.org/issue4431が見つかりました/ MTスイッチマニフェストを使用して作成されていないと解決策は/マニフェストをリンカーフラグに追加することです。さてさて、みましょう編集pylzmaのsetup.pyはMSVCコンパイラのためにそのリンカフラグを追加します。

if isinstance(self.compiler, MSVCCompiler): 
     # set flags only available when using MSVC 
     ext.extra_link_args.append('/MANIFEST') # force linker to create manifest 
     if COMPILE_DEBUG: 
      ext.extra_compile_args.append('/Zi') 
      ext.extra_compile_args.append('/MTd') 
      ext.extra_link_args.append('/DEBUG') 
     else: 
      ext.extra_compile_args.append('/MT') 

ほら、pylzmaは現在、MSVCの罰金を構築します。私は、Python 2.4から2.7の32ビットと建物をテストしているし、2.6から2.7の64ビット:すべてのエラーに対する一般的なアプローチのよう

08.02.2011 10:08   71 844 pylzma-0.4.3dev-py2.4-win32.egg 
08.02.2011 10:09   71 480 pylzma-0.4.3dev-py2.5-win32.egg 
08.02.2011 10:07   79 358 pylzma-0.4.3dev-py2.6-win-amd64.egg 
08.02.2011 10:09   75 637 pylzma-0.4.3dev-py2.6-win32.egg 
08.02.2011 10:08   79 259 pylzma-0.4.3dev-py2.7-win-amd64.egg 
08.02.2011 10:09   75 540 pylzma-0.4.3dev-py2.7-win32.egg 
       6 File(s)  453 118 bytes 

は - それはおそらくその背後に何があるかを理解するためにいくつかの知識と経験が必要です。

+1

[pylzma on github](https://github.com/fancycode/pylzma)に変更を提出する必要があります。これはおそらく、同じ問題を抱えている他の人がいるからです。 – Velociraptors

+0

Zartは、著者のウェブサイト(http://aura.zartsoft.ru/~zart/pypi/pylzma-fix-msvc-compiling.diff)にdiffファイルのURLを投稿しました。 – Xavier