I want my cython program to be standalone executable on linux, not to be imported. After
cython --embed
i got a c file,now how can i make it executable?
I guess you have to compile the .c file you have obtained.
Assuming you are using python 3.5 and don't have to link to other libraries than python you can do this with a simple gcc command like :
gcc -I /usr/include/python3.5m -o your_program your_file.c -lpython3.5m
(you might need to remove the m following the version number)
As you expect it will use the if __name__ == "__main__": statement as entry-point of the program.
m indicates that python was compiled with the support of PyMalloc, in a few words a more efficient allocator function than malloc system ones (see stackoverflow.com/a/16677339/5050917 or python.org/dev/peps/pep-3149 for more details). The if __name__ == "__main__": isn't mandatory, you can also just let unindented the code you want to be executed when the program starts, exactly as when running it with python.ldconfig -p | grep python3.5 to see the libraries installed on your system. In my case i can see that I only have libpython3.5m to link against.
importable in Python or are you trying to embed python and execute it? Please edit your question and elaborate on these to make it a bit easier for use to get what you're trying to do.