473,657 Members | 2,419 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

statically linked python

Hi:

I have searched the docs and google but have not totally figured
out how to accomplish my task: On a linux box, I want to compile
and link python so that it uses no shared libraries, but does support
import of some "extra" modules. I have made a few attempts but
with limited success. In particular, I have tried things like
adding -static to the compiler options in the Makefile.

At one point I managed to build a python that was close to what I
wanted, e.g. when I ran "ldd python", it said:
not a dynamic executable
In that version, when I do some imports, e.g. sys, os, etc. they
load fine. But, when I try to import some other modules, e.g. time,
they are not found. I have tried similar procedures while also
altering Modules/Setup.local (produced by configure) to contain:
time timemodule.c # -lm # time operations and variables

There has to be a simple, "elegant" way to accomplish this which I am
simply overlooking. Any help would be appreciated.

Thanks.
--ralph
Jun 17 '06 #1
3 2380
Ralph Butler wrote:
Hi:

I have searched the docs and google but have not totally figured
out how to accomplish my task: On a linux box, I want to compile
and link python so that it uses no shared libraries, but does support
import of some "extra" modules. I have made a few attempts but
with limited success. In particular, I have tried things like
adding -static to the compiler options in the Makefile.

At one point I managed to build a python that was close to what I
wanted, e.g. when I ran "ldd python", it said:
not a dynamic executable
In that version, when I do some imports, e.g. sys, os, etc. they
load fine. But, when I try to import some other modules, e.g. time,
they are not found. I have tried similar procedures while also
altering Modules/Setup.local (produced by configure) to contain:
time timemodule.c # -lm # time operations and variables

There has to be a simple, "elegant" way to accomplish this which I am
simply overlooking. Any help would be appreciated.


This has nothing to do with python. glibc doesn't support loading
shared libraries into statically linked executables. At least it didn't
support in 2002:
http://www.cygwin.com/ml/libc-alpha/.../msg00079.html
Since it still doesn't work most likely it is still not supported, but
you may ask glibc developers what is the problem.

Jun 17 '06 #2
Serge Orlov wrote:
Ralph Butler wrote:
Hi:

I have searched the docs and google but have not totally figured
out how to accomplish my task: On a linux box, I want to compile
and link python so that it uses no shared libraries, but does support
import of some "extra" modules. I have made a few attempts but
with limited success. In particular, I have tried things like
adding -static to the compiler options in the Makefile.

At one point I managed to build a python that was close to what I
wanted, e.g. when I ran "ldd python", it said:
not a dynamic executable
In that version, when I do some imports, e.g. sys, os, etc. they
load fine. But, when I try to import some other modules, e.g. time,
they are not found. I have tried similar procedures while also
altering Modules/Setup.local (produced by configure) to contain:
time timemodule.c # -lm # time operations and variables

There has to be a simple, "elegant" way to accomplish this which I am
simply overlooking. Any help would be appreciated.


This has nothing to do with python. glibc doesn't support loading
shared libraries into statically linked executables. At least it didn't
support in 2002:
http://www.cygwin.com/ml/libc-alpha/.../msg00079.html
Since it still doesn't work most likely it is still not supported, but
you may ask glibc developers what is the problem.


I do not want to load them. I want to statically link the code for a
module (e.g. time) directly into the statically linked executable.
Sorry if that was not clear.
Jun 18 '06 #3
Ralph Butler wrote:
Serge Orlov wrote:
Ralph Butler wrote:
Hi:

I have searched the docs and google but have not totally figured
out how to accomplish my task: On a linux box, I want to compile
and link python so that it uses no shared libraries, but does support
import of some "extra" modules. I have made a few attempts but
with limited success. In particular, I have tried things like
adding -static to the compiler options in the Makefile.

At one point I managed to build a python that was close to what I
wanted, e.g. when I ran "ldd python", it said:
not a dynamic executable
In that version, when I do some imports, e.g. sys, os, etc. they
load fine. But, when I try to import some other modules, e.g. time,
they are not found. I have tried similar procedures while also
altering Modules/Setup.local (produced by configure) to contain:
time timemodule.c # -lm # time operations and variables

There has to be a simple, "elegant" way to accomplish this which I am
simply overlooking. Any help would be appreciated.


This has nothing to do with python. glibc doesn't support loading
shared libraries into statically linked executables. At least it didn't
support in 2002:
http://www.cygwin.com/ml/libc-alpha/.../msg00079.html
Since it still doesn't work most likely it is still not supported, but
you may ask glibc developers what is the problem.


I do not want to load them. I want to statically link the code for a
module (e.g. time) directly into the statically linked executable.
Sorry if that was not clear.


OK, so you're asking how to make a module builtin. I haven't done that
myself, but let me give you a hint where to look: there is list of
builtin modules sys.builtin_mod ule_names if you search the whole python
source distribution for some of the names in the list you'll get list
of files where to look. I've just searched and found that only two
files are involved: PC\config.c and setup.py

Jun 20 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1734
by: Ville Vainio | last post by:
Came across this via daily python url (which everybody reads anyway :) http://boo.codehaus.org/ Read the manifesto at http://boo.codehaus.org/BooManifesto.pdf Perhaps that .NET / Mono thing is going to be worthwhile after all. Projects seem to be suprisingly succesful on it.
5
3289
by: arve.knudsen | last post by:
Hi I'm trying to build a Python package that I can use on different Linux setups, for this purpose it would be nice to weld external dependencies (libraries) into Python itself. So far I've succeeded in getting Tcl/Tk statically linked in, with the help of Modules/Setup.local, but the same procedure for ncurses and readline results in python being dynamically linked with these two libraries?? That is, there are no longer any readline.so...
1
1790
by: David Douthitt | last post by:
I have a binary statically linked application that was compiled against Red Hat 7.3 (presumably glibc 2.2.5). The application SegFaults when run in a Red Hat Advanced Server environment - with glibc 2.3.2. I had another binary (Samhain - to which I have source!) which had the same problem and exhibited the same strace. After a recompile, the newly compiled static binary worked fine. Why is this? The first binary I don't have source...
0
1089
by: Frank Duan via .NET 247 | last post by:
Hi, I am trying to create a Windows User Control, which uses a commercial native C dll and will be hosted in IE. Using P/Invoke to call C dll functions in Windows User Control (written in C#) has been turned out not working (as we have to install the C dll to the client machine. This does not meet our requirements). So I am thinking about converting this C dll into a .NET dll in MC++. Then this .NET dll can be used in my C# Windows User...
0
1059
by: John Murtari | last post by:
Folks, We'd like to build a version of the command line PHP (i.e. don't plan on running/building the apache module) and have it statically linked to minimize other system dependencies. Has anyone actually done this? Don't see much on the web, a few folks offered changing configure to add LDFLAGS=-all-static , but that doesn't seem to do it?
8
2075
by: bonk | last post by:
Is it generally OK for an EXE that has MFC linked statically to load an use another DLL wich has MFC linked as shared DLL ? To be more specific: I have an EXE that links a lib. Let's call it mylib.lib. That Lib as well as the EXE have MFC linked statically. Then in a completely different project I have a regular DLL, wich is compiled with the /CLR switch and therefore needs the special CRT libs as
2
2471
by: google | last post by:
I statically link the Synopsys Milkyway C-API library ("MDA") into my C++ application. When my C++ application throws an exception, it seg faults instead. The details of my environment are: x86 (Pentium) CPU or AMD x86_64 (Opteron) Red Hat Enterprise Linux 3 OS gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-54) Also reproduced with gcc version 3.3.2
20
2126
by: pratap | last post by:
Could someone clarify how could one reduce the size of an executable code during compile time. Could one use specific compile time flag with makefile or is it advisable to go for dynamic linking. The idea here is that smaller the code size the faster is the code. Is Dynamically linked executable really faster than a single executable file which is not linked dynamically.? Is there any performance measuring metrics on gcc version 3.2.2
12
34360
by: tvnaidu | last post by:
I am getting this link error, I am using mongoose web server with Linux, any idea?: mongoose.c:3114: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking mongoose.c:3081: Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
0
8402
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8829
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8508
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8608
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7341
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6172
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4164
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4323
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2733
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.