public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* RE: Errors creating executable for python script using cython and gcc
       [not found] <001801d87ea9$aaa718c0$fff54a40$.ref@sbcglobal.net>
@ 2022-06-12 22:13 ` jschwar
  0 siblings, 0 replies; 2+ messages in thread
From: jschwar @ 2022-06-12 22:13 UTC (permalink / raw)
  To: gcc-help

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@sbcglobal.net <jschwar@sbcglobal.net> 
Sent: Sunday, June 12, 2022 12:59 PM
To: 'gcc-help@gcc.gnu.org' <gcc-help@gcc.gnu.org>
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.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Errors creating executable for python script using cython and gcc
       [not found] <000001d87e86$277cd700$76768500$.ref@sbcglobal.net>
@ 2022-06-12 17:59 ` jschwar
  0 siblings, 0 replies; 2+ messages in thread
From: jschwar @ 2022-06-12 17:59 UTC (permalink / raw)
  To: gcc-help

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.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-06-12 22:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <001801d87ea9$aaa718c0$fff54a40$.ref@sbcglobal.net>
2022-06-12 22:13 ` Errors creating executable for python script using cython and gcc jschwar
     [not found] <000001d87e86$277cd700$76768500$.ref@sbcglobal.net>
2022-06-12 17:59 ` jschwar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).