1

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?

2
  • 2
    C in general needs to be compiled specifically for each platform. The code might be compatible, though. Commented Dec 9, 2013 at 6:31
  • Look into cross-compilation. Commented Dec 9, 2013 at 7:30

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

1 Comment

I have a Cython post you may be able to provide insight on.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.