ask help for problem with static linking (fwd)

Michael Muller proteus at
Sat Jun 5 20:48:40 CEST 1999

Xiaohong Yuan wrote:
> I am sorry I didn't make it clear. In my C extension module, I declare
> some extern variables. Those extern variables are for my own application.
> They can not be found in Python interpreter source code. So when I do
> static linking, my c extension module fails to be linked with the python
> interpreter. I don't want to add into Python source code the definition of
> my extern variables. There might be some way to wrap my c extensions such
> that extern variables would not cause a problem. My platform is QNX, my
> compiler is watcom compiler. I don't think platform and compiler matter,
> the problem might be how should I deal with extern variable when writing
> python c extensions.
> --Xiaohong Yuan

I am assuming that you mean that your externs are defined in some main
program that your extension is normally linked to, and are presumably
to share information between your extension and your main program.  If
is the case syou have two options:

1) redesign your extension so that the information shared by your
   variables is shared through an API instead.  If necessary, this
   information can be stored statically in the extension library.

2) Create a stub file which is linked to your extension that provides
   bogus (but useable) definitions for these variables.

Method 2 is a hack.  Information that needs to be shared between
should almost always be shared using an API.  This allows a "loose
coupling" of components, so that you can make implementation changes 
in one without affecting the other.

michaelMuller = proteus at |
If you are not willing to control your own mind, there are plenty of
people who are willing to do it for you.

More information about the Python-list mailing list