1

Following the steps here and the Cython Rectangle example, I am trying to compile it manually with gcc 64 bits on windows. The three steps mentioned in the link are (I adapted step 3 for windows, but it could be wrong):

  1. cython --cplus rect.pyx -> rect.cpp
  2. gcc -c Rectangle.cpp -> Rectangle.o
  3. gcc -shared -fPIC -IC:\Users\python37\include rect.cpp Rectangle.o -lstdc++ -o -rect.so

But when doing step 3, I get a list of messages of the type of

C:\Users\xxxx\AppData\Local\Temp\ccu0rCb7.o:rect.cpp:(.text+0x1b8): undefined reference to __imp_PyDict_Size

C:\Users\xxxx\AppData\Local\Temp\ccu0rCb7.o:rect.cpp:(.text+0x222): undefined reference to __imp__PyDict_GetItem_KnownHash

Any idea how to solve this?

Community
  • 1
  • 1
A.P.
  • 461
  • 2
  • 8
  • 17
  • Got it to work by changing step 3 to: `gcc -shared -fPIC -IC:\Users\python37\include -LC:\Users\python37\libs rect.cpp Rectangle.o -lstdc++ -o rect.pyd -lpython37`. Also a detail, it doesn't work from within my python env, but it works if I first deactivate my python env before doing the three steps. Not sure why. – A.P. Jan 26 '19 at 16:21
  • Possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – J.J. Hakala Feb 16 '19 at 15:21

0 Answers0