How I can compile python2.7 to a static lib in Windows? And how I can use these lib within my project (with Python embedded Python C/API).
Asked
Active
Viewed 174 times
2
-
1What is the question? What "python" do you want to compile? A python script? And what is "Python embedded Python C/API" supposed to mean? – Theolodis May 28 '14 at 09:42
-
2I guess Dmitry is trying to compile python2.7.dll as static lib, to use Python C API in his C++ program without installing Python on system. – Arkady May 28 '14 at 09:54
-
1@Arkady That's right. – Dmitry_Mahrachev May 28 '14 at 10:48
-
I will follow this topic, if someone will tell you solution. I failed with trying to use Python C API without Python installation. – Arkady May 28 '14 at 12:01
-
By looking at the `makefile` and `configure.sh`, the `makefile` defines a `$LIBRARY` target and the `configure.sh` script defines that as [this](http://hg.python.org/cpython/file/474c97a5f0c8/configure#l5410). Similar targets must exist for MSVC. – dilbert May 28 '14 at 12:02
-
For the `nmake` build, I think [this](http://hg.python.org/cpython/file/474c97a5f0c8/PC/python3.mak#l4) might be the target you want. – dilbert May 28 '14 at 12:06
-
I create static lib. But next question is how I can include it(.lib) in main program on C++? – Dmitry_Mahrachev May 28 '14 at 15:42
-
That will just require using the desired functions in the C++ program, calling the necessary initialisation functions, and linking to the Python library with the appropriate linker flags. What compiler are you using? – dilbert May 28 '14 at 22:36
-
@dilbert I use VS 2010 for compiling – Dmitry_Mahrachev May 29 '14 at 13:01