public inbox for
 help / color / mirror / Atom feed
From: <>
To: <>
Subject: Errors creating executable for python script using cython and gcc
Date: Sun, 12 Jun 2022 12:59:24 -0500	[thread overview]
Message-ID: <000001d87e86$277cd700$76768500$> (raw)
In-Reply-To: <000001d87e86$277cd700$76768500$>

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): 



if name == "main": 



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


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


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.

       reply	other threads:[~2022-06-12 17:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <000001d87e86$277cd700$76768500$>
2022-06-12 17:59 ` jschwar [this message]
     [not found] <001801d87ea9$aaa718c0$fff54a40$>
2022-06-12 22:13 ` jschwar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='000001d87e86$277cd700$76768500$' \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).