0

probably I have taken a long route, but for some reason, I have to call a python routine from fortran. So, I have use cython. Cython has generated the C code.

As per cython document, I tried to compile the code. The shared lib (.so) file is generated without problem, but I cant compile the C file to executable.

I tried compiling it using info given here. I have also checked the accepted answer here, but in my linux system, the libpython does not exist(may be somwhere else to look at?)

gcc -c -I/usr/include/python3.4/ parse.c
gcc  -I/usr/include/python3.4m/  -L/usr/lib64/python3.4/site-packages/ parse.c -lpython
/usr/bin/ld: cannot find -lpython
collect2: error: ld returned 1 exit status

So, is there any way to compile the C file generated by python? Or, alternatively, can I use the generated so file(I guess I need the lpython any way).

So, at present, the question is:

  1. How to compile C code generated by cython?

  2. where I can found the libpython.so if fedora-linux?

    The pyx (or the python code is:) https://drive.google.com/file/d/0B02WblgE6NEvenNYT1RoVmMyM3M/view?usp=sharing (Somehow the code formatting here did not worked, so, uploaded it in drive)

Community
  • 1
  • 1
BaRud
  • 3,055
  • 7
  • 41
  • 89
  • On my system, I don't have a `libpython.so`. Instead, I have `libpython2.7.so` and `libpython3.4m.so`. It is located in /usr/lib64/``. Maybe you should try `-lpython3.4m` and, if this folder is not already searched by default `-L/usr/lib64/`! – Alexander Vogt Feb 26 '15 at 15:32
  • Thanks. Bit thats giving me error: `gcc -L/usr/lib64/ parse.o -lpython2.7 /usr/lib/gcc/x86_64-redhat-linux/4.9.2/../../../../lib64/crt1.o: In function `_start': (.text+0x20): undefined reference to `main' collect2: error: ld returned 1 exit status` – BaRud Feb 26 '15 at 16:30
  • You are trying to compile it as a main program. You must use `-c`. – Vladimir F Героям слава Feb 26 '15 at 21:47

0 Answers0