testpyd.pyd
주의 : 모든 source 및 출력은 소문자로
1.Visual Studio를 이용하여 win32 DLL Project 만들기
2.c/c++ -> include directory 추가
- c:\python34\include
- C:\python34\lib\site-packages\numpy\core\include
3.linker에서 library path 추가 및 종속성에 python lib추가
- c:\python34\libs
- python34.lib
4.linker에서 출력 파일을 testpyd.pyd 로 변경
5.기존 testpyd.cpp 파일은 삭제
6.testpyd.pyx 파일 생성
import ctypes
import numpy as np
cimport numpy as np
cpdef publiic int cy_sum(int a, int b):
return a+b
7.cython을 이용하여 testpyd.cpp 파일 generate
cython -3 -o testpyd.cpp testpyd.pyx
-3 : python-3
-o : output source file
8.visual sutdio에서 rebuild 수행
9.test
C:\testpyd>ipython3 --pylab으로 실행 후
>import testpyd
>testpyd.cy_test(10)
55