Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the procedure for generating a dll-independent exe with Python

Shulou Source: shulou.com Published: 2022-06-02 23:25:09 10月27日 Update

Python does not rely on the exe generated by the operation of the steps is what kind of, I believe that many people do not have experience in this helpless, this article summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.

1: Download Python Version 2.5.4 Source Code

2: Extract to F:\study\python\Python-2.5.4

3: Go to F:\study\python\Python-2.5.4\PCbuild8 and open the solution pcbuild.sln

Open F:\study\python\Python-2.5.4\PCbuild8\pcbuild.sln with vc 2005

4: Open the configuration properties of pcbuild solution and check the ones to be built, remove all of them, and only check the pythoncore project.

5: Change Code generation type to/MT in c/c++ configuration

6: Change the configuration type of pythoncore configuration properties to static lib

7: To implement static compilation embed Python generate dll independent exevc2005 + python 2.5.4 make a statically linked exe program, you need to change the output file of libray of pythoncore project active release to: $(OutDir)\python25.lib

8: Compile the project to generate F:\study\python\Python-2.5.4\PCbuild8\win32release\python25.lib

Above compiled a statically linked library python25.lib

9: Create a new solution F:\study\python\vc\test\test.sln

10: Add a file main.cpp

contents are as follows

#include #include int main() { Py_Initialize(); PyRun_SimpleString("print 'i am a static python exe!!! '"); Py_Finalize(); getchar(); return 0; } After reading the above content, do you know how to use Python to generate exe that does not depend on dll? If you still want to learn more skills or want to know more related content, welcome to pay attention to the industry information channel, thank you for reading!

Tags: Build content engineering static compilation steps solutions methods more solutions links problems helpless for this reason skills files source code version Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno NVidia Microsoft Xiaomi macOS