Creation of Windows executable file (*.exe) with PyDev-Eclipse and CDT-Eclipse — How?

混江龙づ霸主 提交于 2019-12-11 00:34:16

问题


Is it possible to create Windows executable files for Python and C/C++ code within the Eclipse workbench? If yes, then how can this be done?


回答1:


This is how I create .exe files from eclipse, in windows. Is not within the eclipse workbench but it might help you. To avoid problems, I would recommend to download everything for 32 bit even if you use 64 bit computer.

Install python 2.6

Install Eclipse

Install py2exe

In eclipse go to Help > Install new software and install pydev plugin from http://pydev.org/updates/

In windows preferences point the python interpreter to the location of your python.exe in your computer (C:/Python26)

you might need to add py2exe to the libraries

create a python module called setup.py with a code similar to this one:

from distutils.core import setup
import py2exe

setup(windows=['H:/yourworkspace/YourPythonProject/src/yourprogram.py'])

open windows console and type python H:/yourworkspace/YourPythonProject/src/setup.py py2exe

this will create a .exe located in C:/Python26/dist folder. It should work if you double click it but you cannot take it to a computer without python or any of the libraries that you´ve used. To do that, you can use Inno Setup.

It's very easy to use, basically it will ask for the location of the .exe, the dlls and folders that you want to add (I don't know about this so I add most of the things inside my C:/Python26/dist and it works). Inno setup will create an script and generate a .exe that you can install in any computer. You might need to edit the [Icons] part of the script, I had problems with that before to add an icon to the application.

That should hopefully work,

good luck.




回答2:


Not sure I understand what you're asking as you're mixing Python/C++ in your question...

If you want to embed Python in some library, Google for 'embed python in c++'

If you just want to package Python to run Python code with extension modules, search for py2exe or cx-Freeze (personally, I like cx-Freeze better).

I don't think any of this is PyDev/Eclipse dependent (this should be IDE agnostic).




回答3:


In addition to Fabio's answer:

In terms of C/C++, if you compile it on windows, eclipse does create yourprog.exe file automaticaly in order to be executed (in case if you have your main function written in C/C++). Look for your executable in bin folder of your project.

In terms of compiler: I use Cygwin. It simulates Linux environment. It contains (not by default though) g++ compiler, which, because of cygwin, compiles it in binary that can be launched in Windows (i.e. .exe file). I am not sure exactly about whether Linux binary is then converted to Windows binary or it is directly compiled for windows, but I know that this .exe file alone works if you run it.

Let me know if you need help installing Cygwin.



来源:https://stackoverflow.com/questions/11187568/creation-of-windows-executable-file-exe-with-pydev-eclipse-and-cdt-eclipse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!