用Python生成不依賴dll的exe的操作步驟簡介
在實際操作中如果我們將靜態(tài)編譯嵌入Python生成了不依賴dll的exe的話,你就可以通過用vc2005 與python 2.5.4并用,來制造一個靜態(tài)鏈接的exe的相關(guān)程序,以下是文章的具體內(nèi)容的詳細(xì)介紹。
1: 下載 python2.5.4版本源代碼
2: 解壓到 F:\study\python\Python-2.5.4
3: 進入F:\study\python\Python-2.5.4\PCbuild8 ,打開解決方案 pcbuild.sln
即用vc 2005打開 F:\study\python\Python-2.5.4\PCbuild8\pcbuild.sln
4: 打開pcbuild solution的configuration properties 將 要build的勾選,全部去掉,只勾選pythoncore工程。
5: 更改c/c++ 配置里的Code genration 類型為 /MT
6: 更改pythoncore configuration properties 的configuration type 為: static lib
7: 要實現(xiàn)靜態(tài)編譯嵌入Python生成不依賴dll的exevc2005 + python 2.5.4 制造一個 靜態(tài)鏈接的exe程序中,你需要更改pythoncore工程 active release 的libray的 output file 為:$(OutDir)\python25.lib
8: 編譯工程 ,生成F:\study\python\Python-2.5.4\PCbuild8\win32release\python25.lib
上面編譯了一個靜態(tài)鏈接的庫python25.lib
9: 建立一個新解決方案F:\study\python\vc\test\test.sln
10: 添加一個文件main.cpp
內(nèi)容如下
- #include <python.h>
- #include <stdio.h>
- int main()
- {
- Py_Initialize();
- PyRun_SimpleString("print 'i am a static python exe!!!'");
- Py_Finalize();
- getchar();
- return 0;
- }
以上就是對靜態(tài)編譯嵌入Python生成不依賴dll的exe@@@@相關(guān)的內(nèi)容的介紹,望你會有所收獲。