1

I am just getting started with Cython and am trying to compile a "Hello World" script. I am trying to use gcc -Os /User/Documents/Python/Test\ Python/helloCopy.c -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -l, but I don't know what to add after the -l. Other forum pages say to "include -lpython2.7 (or whatever version of Python you're using) on the linker command-line" but that produces ld: library not found for -lpython3.5 clang: error: linker command failed with exit code 1 (use -v to see invocation) Should I be directing the -l to a particular folder?

1 Answers1

0

I do not know what resource you're using, but this does not say anything about a -l flag. It suggests

cython -a helloCopy.pyx

This creates a yourmod.c file, and the -a switch produces an annotated html file of the source code. Pass the -h flag for a complete list of supported flags.

gcc -shared -pthread -fPIC -fwrapv -O2 -Wall -fno-strict-aliasing -I/usr/include/python2.7 -o helloCopy.so helloCopy.c

(Linux)

On macOS I would try to compile with

gcc -I/usr/bin/python -o helloCopy.so helloCopy.c

to use the standard version of Python.

Community
  • 1
  • 1
pingul
  • 3,351
  • 3
  • 25
  • 43
  • Both of these produced an error of `Undefined symbols for architecture x86_64: "_PyBytes_FromStringAndSize", referenced from: _PyInit_helloCopy in helloCopy-d342ea.o ___Pyx_InitStrings in helloCopy-d342ea.o "_PyCode_New", referenced from:` ... a whole bunch more `ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)` – Connor Tingley Mar 28 '17 at 00:40
  • Also, how would I figure out what resource I am using? – Connor Tingley Mar 28 '17 at 01:07
  • @ConnorTingley I found [this](http://stackoverflow.com/questions/5105482/compile-main-python-program-using-cython) which I think you used as reference before. Do you have `python-dev` installed? – pingul Mar 28 '17 at 08:03
  • I think I do, because I am able to include the python3.5m folder successfully, but I might be totally wrong. – Connor Tingley Mar 29 '17 at 04:19