Suppose I have a library written in Python that I'd like to call from a C software. Is there any way I can compile this Python code to a .so file?
-
A little research wouldn't hurt: stackoverflow.com/questions/11436484/…Filipe Gonçalves– Filipe Gonçalves2014-04-12 22:40:23 +00:00Commented Apr 12, 2014 at 22:40
-
@FilipeGonçalves probably due to low views both of those questions didn't appear in my Googling.Mauren– Mauren2014-04-12 22:44:23 +00:00Commented Apr 12, 2014 at 22:44
-
Probably searching with the right term might be a bit of issue in this case. Google gives much better results if right terms are knownfkl– fkl2014-04-13 00:12:26 +00:00Commented Apr 13, 2014 at 0:12
Add a comment
|
1 Answer
This should help.
Also you can do both ways i.e. extend python by writing library in C and call it from Python code OR code functions in C that could be called from Python.
The standard term used (conceptually and help googling is "Python bindings"
4 Comments
user13107
Could you answer a related question stackoverflow.com/questions/50459248/…
fkl
sure - getting page not found for the link??
ilias iliadis
The question is very-very clear. I am not sure why this shows up as an answer at all. The first (assumed as the main) link starts with «There are several ways to call code written in C from Python» which is the exact opposite of the, included in the question, «I'd like to call from a C software». The rest is about «doing it both ways»!? (probably for some other question).
fkl
Whether one needs to call python to c or c to python, the requirement is to understand how "python bindings work" which is the first reference and which is why it latter talks about doing it either way. The next link "Official reference .." is indeed "Calling Python functions from C". Hope that helps