How to compile .c code from Cython with gcc

后端 未结 2 1507
孤街浪徒
孤街浪徒 2020-12-01 05:39

Now that I\'ve successfully installed Cython on Windows 7, I try to compile some Cython code using Cython, but gcc makes my life hard.

cdef void say_hello(na         


        
相关标签:
2条回答
  • 2020-12-01 06:08

    Try:

    gcc -c -IC:\Python27\include -o ctest.o ctest.c
    gcc -shared -LC:\Python27\libs -o ctest.pyd ctest.o -lpython27
    

    -shared creates a shared library. -lpython27 links with the import library C:\Python27\libs\libpython27.a.

    0 讨论(0)
  • 2020-12-01 06:28

    That is a linker (ld) error and not a compiler error. You should provide the path to the library (-l and -L) and not only to the headers (-I).

    0 讨论(0)
提交回复
热议问题