1

マシン構成: 私の構成は Windows 7 x64 で、python 2.7 と cython 0.18 (すべて 64 ビット) がインストールされています。MS C++ 2008 Visual Studio もインストールしています。

GSL バイナリがあり、Path が GSL\Bin を指しています。

MS VS 2008 + SDK 7.0 を使用して cython .pyx ファイルをコンパイルしています。SDK 7.0 コマンド プロンプトを使用して、c および cython にコンパイルします。

問題 しかし、コンパイル時にリンク エラー 2019 が表示されます。これは、GSL フォルダー内のヘッダー ファイルが見つからないことを示しています。

私の試み これを解決するために、CythonGSL をダウンロードしました。「from cythonGSL cimport *」を使用しても機能しませんでした。このパッケージの init ファイルに移動し、GSL をインストールした場所に合うように、検索しているように見えるディレクトリを変更しました。CythonGSL の readme に示されているように、setup.py を更新しました。

これもうまくいきませんでした!! コンパイル時に、gsl.lib が見つからないと表示されます。

どうすればこれを修正できますか?

1つのオプションは、たとえば、代わりに静的アドレスを指すことができるかどうかです

    cdef extern from "libcalg/queue.h":
       with
    cdef extern from "FUll File Path/queue.h":

それは今のところうまくいきません。

setup.py

from distutils.core import setup
from Cython.Distutils import Extension
from Cython.Distutils import build_ext
import cython_gsl
import numpy as np
setup(

    include_dirs = [cython_gsl.get_include(), np.get_include()],
    cmdclass = {'build_ext': build_ext},
    ext_modules = [Extension("lda_gibbs_cython",
                             ["lda_gibbs_cython.pyx"],
                             libraries=cython_gsl.get_libraries(),
                             library_dirs=[cython_gsl.get_library_dir()],
                             include_dirs=[cython_gsl.get_cython_include_dir()])]
    )

唯一の違いは、np.get _include() を含めることです。

私の .pyx ファイル: ( https://github.com/twiecki/CythonGSL/blob/master/examples/gibbs.pyxからテスト用に借用 )

import numpy as np
cimport numpy as np
cimport cython
DTYPE = np.int
ctypedef np.int_t DTYPE_t
from scipy.special import gammaln
from cython_gsl cimport *

cdef gsl_rng *r = gsl_rng_alloc(gsl_rng_mt19937)

Cython GSL 試行からのエラー メッセージ:

D:\LDA\pythonLDA>setup.py build_ext --inplace
running build_ext
cythoning lda_gibbs_cython.pyx to lda_gibbs_cython.c
building 'lda_gibbs_cython' extension
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\Bin\amd64\cl.exe /c /nolog
o /Ox /MD /W3 /GS- /DNDEBUG -IC:\Python27\lib\site-packages -IC:/GSL/include -IC
:\Python27\lib\site-packages\numpy\core\include -IC:\Python27\include -IC:\Pytho
n27\PC /Tclda_gibbs_cython.c /Fobuild\temp.win-amd64-2.7\Release\lda_gibbs_cytho
n.obj
lda_gibbs_cython.c
c:\python27\lib\site-packages\numpy\core\include\numpy\npy_deprecated_api.h(8) :
 Warning Msg: Using deprecated NumPy API, disable it by #defining NPY_NO_DEPRECA
TED_API NPY_1_7_API_VERSION
lda_gibbs_cython.c(2812) : warning C4244: 'function' : conversion from '__int64'
 to 'long', possible loss of data
lda_gibbs_cython.c(4811) : warning C4101: 'getbuffer_cobj' : unreferenced local
variable
lda_gibbs_cython.c(4842) : warning C4101: 'releasebuffer_cobj' : unreferenced lo
cal variable
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\Bin\amd64\link.exe /DLL /n
ologo /INCREMENTAL:NO /LIBPATH:C:/GSL/lib /LIBPATH:C:\Python27\libs /LIBPATH:C:\
Python27\PCbuild\amd64 gsl.lib gslcblas.lib /EXPORT:initlda_gibbs_cython build\t
emp.win-amd64-2.7\Release\lda_gibbs_cython.obj /OUT:D:\LDA\pythonLDA\lda_
gibbs_cython.pyd /IMPLIB:build\temp.win-amd64-2.7\Release\lda_gibbs_cython.lib /
MANIFESTFILE:build\temp.win-amd64-2.7\Release\lda_gibbs_cython.pyd.manifest /MAN
IFEST
LINK : fatal error LNK1181: cannot open input file 'gsl.lib'
error: command 'link.exe' failed with exit status 1181

GCC 試行

標準のcmdウィンドウを使用できるように、TDM-GCCをインストールしました。

.pyx と setup.py は同じままです。ここで文書化され、解決された問題がありました-mno-cygwin : gcc building Mercurial (Windows 2000)。まだ葉巻はありません。これが別の質問であるべきかどうかはわかりません-専門家がそう考える場合は移動します.

D:\LDA\pythonLDA>setup.py build_ext --inplace -c mingw32
running build_ext
skipping 'lda_gibbs_cython.c' Cython extension (up-to-date)
building 'lda_gibbs_cython' extension
C:\MinGW64\bin\gcc.exe -mdll -O -Wall -IC:\Python27\lib\site-packages -IC:/GSL/i
nclude -IC:\Python27\lib\site-packages\numpy\core\include -IC:\Python27\include
-IC:\Python27\PC -c lda_gibbs_cython.c -o build\temp.win-amd64-2.7\Release\lda_g
ibbs_cython.o
writing build\temp.win-amd64-2.7\Release\lda_gibbs_cython.def
C:\MinGW64\bin\gcc.exe -shared -s build\temp.win-amd64-2.7\Release\lda_gibbs_cyt
hon.o build\temp.win-amd64-2.7\Release\lda_gibbs_cython.def -LC:/GSL/lib -LC:\Py
thon27\libs -LC:\Python27\PCbuild\amd64 -lgsl -lgslcblas -lpython27 -l -o D:\LDA\pythonLDA\lda_gibbs_cython.pyd
gcc: error: D:\LDA\pythonLDA\lda_gibbs_cython.pyd: No such file or direct
ory
error: command 'gcc' failed with exit status 1
4

1 に答える 1