1

I am trying to compile a python program to c file.First, After going through and eliminating tens of errors with dozens of linking flags, finally left with a single error. When I type:

$ gcc -Os -I /usr/include/python3.6m -o example example_cy.c -lpython3.6m     -lpthread -lm -lutil -ldl

the error is:

/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':                                                
(.text+0x20): undefined reference to `main'                                                                                                          
collect2: error: ld returned 1 exit status

Then I add -nostartfiles:

gcc -Os -I /usr/include/python3.6m -o example example_cy.c
-lpython3.6m -lpthread -lm -lutil -ldl -nostartfiles

The error becomes:

/usr/bin/ld: warning: cannot find entry symbol _start; defaulting to  
00000000000022f0

I got the image that the problem is roughly do have neither main nor _start function in my .c file.

Hakan Demir
  • 307
  • 2
  • 4
  • 12
  • 1
    That's correct. Better go with a `main()` function and drop the `-nostartfiles` thingie. What's your exact question or problem here? – Ctx Mar 07 '19 at 23:28
  • Possible duplicate of [Making an executable in Cython](https://stackoverflow.com/questions/22507592/making-an-executable-in-cython) – ead Mar 08 '19 at 08:16
  • cython generates main-method, if you cythonize with --embed. See the duplicate target for more info. – ead Mar 08 '19 at 08:17

0 Answers0