Re: Is it possible to statically link python into gdb?

Joel Brobecker <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <[email protected]>
> I admit that I have to make a compromise here. I am delivering gdb to
> my customer and my expectation is that they can use my gdb with python
> support no matter there is python in their system and no matter the
> version of their installed python. After a lot of attempts, I think I
> can't reach my expectation. I guess I have to live with my above
> workaround.

What we do is statically link Python into GDB, and then distribute
both GDB + Python. As long as the path to Python is inside the
configured prefix, the path to the Python libraries should be
"relocatable", allowing users to install the binary package anywhere
and GDB will always find them.

One thing we also do that's not done in the FSF version of GDB
is the following:

@@ -1680,6 +1680,10 @@ message == an error message without a stack will be printed."),
 #else
   Py_SetProgramName (progname);
 #endif
+
+  /* We override any value that the PYTHONHOME might have, as we want
+     to make sure that we use the Python library that comes with GDB.  */
+  Py_SetPythonHome (ldirname (python_libdir));
 #endif
 
   Py_Initialize ();

Some users have had their own version of Python which may be incompatible
with the version we ship in GDB, so we make sure that within GDB, we use
the Python that we built with.

-- 
Joel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.