2

I'm french, by advance, sorry for my english...

I can make and use on linux a pyd (dll) file with this line

cython -o script.c script.pyx

i586-mingw32msvc-gcc script.c -Wall -I/home/User/.wine/drive_c/Python34/include -shared -o script.pyd /home/User/.wine/drive_c/Python34/libs/libpython34.a

It works very well,

However, I test this line for to create executable Windows on Linux, but it does not work. Why ?

My Line:

cython --embed -o script.c script.pyx

i586-mingw32msvc-gcc -c -I/home/User/.wine/drive_c/Python34/include -L/home/User/.wine/drive_c/Python34/libs script.c -o script.exe

EDIT: wine return, that the file is a bad format executable

EDIT2 : suggestion by Petesh

i586-mingw32msvc-gcc -I/home/User/.wine/drive_c/Python34/include /home/User/.wine/drive_c/Python34/libs/libpython34.a script.c -o script.exe

-c option and libpython34.a added

Result:

undefined reference to `_WinMain@16'

EDIT3 : suggestion by Petesh

i586-mingw32msvc-gcc -municode -I/home/User/.wine/drive_c/Python34/include /home/User/.wine/drive_c/Python34/libs/libpython34.a script.c -o script.exe

-municode option added

Result :

cc1: error: unrecognized command line option "-municode"

EDIT4 :

I replaced 'wmain' in script.c by 'main', the error _WinMain@16 is eliminated, but it remains errors of type

/tmp/ccVWy25J.o:script.c:(.text+0x1084): undefined reference to `__imp__PyObject_Call'
/tmp/ccVWy25J.o:script.c:(.text+0x1186): undefined reference to `__imp__PyTuple_Pack'
/tmp/ccVWy25J.o:script.c:(.text+0x1218): undefined reference to `__imp__PyOS_snprintf'

Thanks by advance,

Fred
  • 1,011
  • 1
  • 10
  • 36
  • The `-c` compiles only, and does not link. As a result the `.exe` file you ask it to build cannot run, as it's really a `.obj` file. You need to remove this argument from the command line. However you also need to re-add the `libpython34.a` reference, as otherwise the code will not link as it will be missing references to that library. – Anya Shenanigans Aug 15 '16 at 08:28
  • @Petesh, thanks... see my edit, an another error appears – Fred Aug 15 '16 at 08:38
  • based on [this question](http://stackoverflow.com/questions/24219012/building-standalone-application-with-cython-mingw) the error is caused by wmain being defined in the `.c` file. If you try to compile with `-municode`, it might work, otherwise you can edit the file and swap the definitions of main/wmain (which will get it to compile, but will break command line parsing) – Anya Shenanigans Aug 15 '16 at 10:29
  • @Petesh, The version edited, thanks – Fred Aug 15 '16 at 15:10
  • Looks like `-municode` isn't supported on the 32bit compiler - see the previously linked question for potential workarounds. This is a mingw compiler and python3 thing. – Anya Shenanigans Aug 15 '16 at 15:21
  • I don't think you need to specify `-municode` on Python 3.x, it is implied by default. – Matt Aug 15 '16 at 15:45
  • @Matt, thanks... Do you have an alternative proposal we should consider? – Fred Aug 15 '16 at 16:09
  • @user1125315 sure but you won't like it... build it on a Windows machine :) https://github.com/cython/cython/tree/master/Demos/embed – Matt Aug 15 '16 at 16:16
  • @Matt, Why to create a library on linux for Windows OS works and create an executable on linux for Windows wouldn't work ? – Fred Aug 16 '16 at 09:48
  • Compiler name i586-mingw32msvc-gcc suggests that the compiler version may be quite old. New version might support that `-municode`. – J.J. Hakala Aug 16 '16 at 21:38
  • @Hakala, thanks, but what compiler ? – Fred Aug 17 '16 at 13:40

0 Answers0