python37.dll not linked in executable

不打扰是莪最后的温柔 提交于 2020-01-06 04:56:07

问题


I extended c++ with python but the exectuable won't run on systems that do not have python installed.

#include "C:\.....python.h"

int main()
{
    Py_Initialize();
    PyRun_SimpleString("print("hello world")\n")
Py_Finalize();
return 0;
}

When I run on a windows system without python installed I receive the following error:

The code execution cannot proceed because python37.dll was not found. Reinstalling the program may fix the problem.

How do I link python37.dll to the executable.


回答1:


A DLL is by definition a dynamically linked library, it is a separate module that is looked up and resolved at run time.

If Python is not installed, your application won't run.

You need to either bundle Python with your application or install Python before/during your application installation.

Alternatively you can try linking with Python statically, in which case it will become part of the executable and won't need to be installed separately.




回答2:


Make sure your python folder is in your PATH so it can find the DLL in question.

From the command line:

c:\> set PATH=c:\python\python37;%PATH%
c:\> cd /d c:\path\to\your\exe
c:\path\to\you\exe> myprogram.exe

For more details about how DLLs are found and loaded read the Dynamic-Link Library Search Order page on MSDN



来源:https://stackoverflow.com/questions/59496003/python37-dll-not-linked-in-executable

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