-1

i am trying to statically link python35.dll to my win32 API application because i have to make it standalone. I have set up include and libraries paths to $(SolutionDir)\inlcude and $(SolutionDir)\libs, respectively and set up runtime library under C/C++->Code Generation to Multi-threaded(/MT). Also i added python35.lib to Linker->Input->Aditional Dependencies.

Now my .exe is working when i have python35.dll in the same folder as .exe, but i have to have that .dll as a part of .exe, so it can be standalone.

I have read many other question here on stackoverflow and tried everything but i am surely missing something. I would appreciate any help.

Thank you in advance.

EDIT: OK, i have to change a topic here because i have done this and found solution and it seems that i have forgotten real problem.

I there some way for me to create wrap python into my winapi program so users of it don't have to install Python to have it working?

Note: Sorry for this kind of questions I don't have much experience in neither Python nor C++. I've also updated title according to new question.

  • You cannot **statically** link a **dynamic** link library. If you want to have a single executable image, you'd have to embed the DLL as a binary resource, and extract it on demand. One way to do this would be to `/DELAYLOAD` the *python35.dll*, and handle the respective callbacks (see [Linker Support for Delay-Loaded DLLs](https://msdn.microsoft.com/en-us/library/151kt790.aspx), and specifically [Understanding the Helper Function](https://msdn.microsoft.com/en-us/library/09t6x5ds.aspx) for details). – IInspectable Aug 09 '16 at 12:11
  • Maybe you just want an installer package so that you have 1 exe to distribute?? – drescherjm Aug 09 '16 at 12:13
  • 2
    This isn't going to work out. You need to swim with the current, not against it. Do make sure that you comply with the Python licence. – David Heffernan Aug 09 '16 at 12:21
  • ***I there some way for me to create wrap python into my winapi program so users of it don't have to install Python to have it working?*** Create an installer package for your application that includes python. However I would check the Python licence first. – drescherjm Aug 10 '16 at 14:28
  • ***EDIT: OK, i have to change a topic here*** Once the question is closed changing the topic will most likely not help. – drescherjm Aug 10 '16 at 14:58
  • @drescherjm If you have a new question, you should just ask a new one instead of changing the topic here. See http://meta.stackoverflow.com/a/317450/247763 – derekerdmann Aug 10 '16 at 17:44

1 Answers1

1

Statically link means to embed a library in your executable. A DLL by definition is a Dynamic Link Library.

If you want to statically link a library you need to build or aquire a prebuilt static library, not a dynamic library. Alternatively simply link dynamically and ship the dll alongside the exe as you have already achieved.

1stCLord
  • 860
  • 5
  • 14