I convert my python script with cython to C file and then compile it with gcc. Is it possible to run output file in any platform?
-
2C in general needs to be compiled specifically for each platform. The code might be compatible, though.Jules Gagnon-Marchand– Jules Gagnon-Marchand2013-12-09 06:31:57 +00:00Commented Dec 9, 2013 at 6:31
-
Look into cross-compilation.soulseekah– soulseekah2013-12-09 07:30:37 +00:00Commented Dec 9, 2013 at 7:30
1 Answer
Nop. Compiling a python extension (via Cython) under Windows will give you a .pyd (which is equivalent to a DLL) while you'll get a .so under Linux (well, it is not an extension matter, but ...). For example, if you built it under Linux, you will have to setup the MinGW Toolchain under Windows, possibly adapt the code for some specific parts and finally recompile with this emulated version of gcc.
If you are targeting Win64, have a look at mingw-w64 instead of the regular MinGW project which is 32-bit only.
Note: To make your code "relatively" portable, use MACROs like, for example:
#ifdef __WIN32__
// do my Windows specific stuff
#else
// ... handle others plateforms
#endif