RE: Errors creating executable for python script using cython and gcc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I figured out part of the problem.  I had the library in my gcc command for
python as -L (path)\Python310\libs.  It should just be -L (path)\Python310.

 

From: jschwar@xxxxxxxxxxxxx <jschwar@xxxxxxxxxxxxx> 
Sent: Sunday, June 12, 2022 12:59 PM
To: 'gcc-help@xxxxxxxxxxx' <gcc-help@xxxxxxxxxxx>
Subject: Errors creating executable for python script using cython and gcc

 

I'm having issues trying to get cython working with the gcc compiler. I want
to use the gcc compiler because I've heard it's harder to get your code from
the executable than using pyinstaller.

 

I'm on 64-bit Windows 10 and my target, for now, is the same.

 

I have an application that is written in python 3.10.4. It is a command line
application that goes against AWS, so there are no Windows calls in it.

 

I can produce the executable using pyinstaller and it runs just fine.

 

my code starts like this: 

 

import src.python.app_name 

import sys 

 

def main(argv): 

   src.python.app_name.main(sys.argv[0:]) 

 

if name == "main": 

   main(sys.argv[0:])

 

However, when I use the cython command to produce the .c module with a
command like this:

 

cython -3 -o app.c app.py src\python\app_name.py 

 

That seems to work just fine or at least it doesn't generate errors.

 

Then I tried to create the executable and I've run into all sorts of
problems that many others have run into on the internet, too.

 

I compile it with this command:

 

gcc -Wall -m64 -I (path)\Python310\include -L (path)\Python310\libs
-lpython310 name.c -o name.exe

 

and I get this: 

 

name.c:220:41: warning: division by zero [-Wdiv-by-zero] 

  220 | enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P ==
sizeof(void*)) }; 

      | ^ 

name.c:220:12: error: enumerator value for '__pyx_check_sizeof_voidp' is not
an integer constant 

  220 | enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P ==
sizeof(void*)) }; 

      | ^~~~~~~~~~~~~~~~~~~~~~~~

 

 

I've tried adding the -DMS_WIN64 option to the gcc command, but then it
sends a bunch of undefined reference  errors regarding  __imp_Py* and it
complains about undefined reference to `WinMain'

 

I have no clue how to fix this. Can someone help me?

 

I'm using gcc version 12.1.0

 

I have a main routine defined like I mentioned. Not a WinMain routine.




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux