0

I want to compile a HelloWorld in Python with Cython using mingw-w64. I could create the HelloWorld.c using this command:

cython --embed -o HelloWorld.c HelloWorld.py

But then I can manage to be able to generate a HelloWorld.exe

I use the following command:

gcc -Os -I C:\Users\user\AppData\Local\Programs\Python\Python36\include -o HelloWorld HelloWorld.c

And I get the following error:

C:/Program Files (x86)/mingw-w64/i686-8.1.0-posix-dwarf-rt_v6-rev0/mingw32/bin/../lib/gcc/i686-w64-mingw32/8.1.0/../../../../i686-w64-mingw32/lib/../lib/libmingw32.a(lib32_libmingw32_a-crt0_c.o):crt0_c.c:(.text.startup+0x39): undefined reference to `WinMain@16'
collect2.exe: error: ld returned 1 exit status

I checked that there aren't any "wmain" like some threads suggest (Compile main Python program using Cython)

Python Version: 3.6
Windows 10
C Compiler: MinGW-w64

HelloWorld.py

def main():
    print("Hello world!")

if __name__== "__main__":
  main()
khelwood
  • 55,782
  • 14
  • 81
  • 108
Decano
  • 93
  • 6

1 Answers1

-2

Using pyinstaller with .pyd extension is one of the easiest solution that you can get. However, I'm not sure whether you can use --embed or not since it may need the .spec or .pyd I guess.

Physicing
  • 532
  • 5
  • 17
  • Thanks, I already tried it with Pyinstaller, the problem is Pyinstaler doesn't hide the code, it only packs it in an exe, so it can be easy decompiled. – Decano Sep 30 '19 at 06:58
  • I'm having similar issue right know and trying nuitka. I will let you know if it works for hiding the code. – Physicing Sep 30 '19 at 07:58