How to call C functions from Linux C executable and vice-versa

Chris Angelico rosuav at gmail.com
Wed Dec 25 11:44:00 EST 2019


On Thu, Dec 26, 2019 at 3:41 AM Manomugdha Biswas <manomugdha at gmail.com> wrote:
>
> Hi,
> I have a Linux C binary (executable, not .so file). i can update (add new
> files/folders if it is required) but after compilation i will get a binary
> executable file.
> I want to access/call few functions of this executable from python. for
> this i want to use cython interface (most probably cython is the best
> option!). Any other possible options are also acceptable.  the
> example/documentation of cython i have seen till now, they talk about
> calling c functions from c library (.so file).
>
> can you please point me to a documentation/source code which talks about
> how to call c functions from c-executable?
>

Once it's an executable, you can't call functions in it. So your
options are either:

1) Go back to the source code and compile it differently. Use it as a
library instead of an executable.

2) Run the program with parameters that make it do what you want, and
then get a result back via stdout.

The first one is almost certainly easier. You'll need to figure out
how the project is structured, and probably learn a bit about the
process of compiling C code to either an executable or a library.

ChrisA


More information about the Python-list mailing list