3

I have a lot of code in Delphi I would like to use in python. In Delphi XE is an option to generate C / C + + files. obj Can I generate these files. Obj in Delphi and use it in python code

python code to use it. obj will still be cross-platform?

thank you

  • If your question left out the spurious idea about obj files it would be a duplicate of this question: Learn to write a Python extension using delphi: http://stackoverflow.com/questions/8244121/creating-python-extension-with-delphi – Warren P Nov 09 '13 at 22:17

1 Answers1

2

Delphi generated .obj files cannot be consumed by Python because Python doesn't consume .obj files. You'd need to compile them to a library at the very least. At which point, emitting .obj files is pointless – you may as well just output a full module. I conclude that you'll need to compile your Delphi code to a library (DLL) or a COM object.

To support multiple platforms, you'll need to compile separately for each platform. Which means that you'll only be able to support platforms on which Delphi compilers exist. FreePascal has wider platform support and may be a better choice.

Obviously COM would restrict you to Windows. So the other option is a library. This can be consumed using ctypes or by making your module a Python extension module.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490