Mailing List Archive

ask help for problem with static linking (fwd)
I am trying to link my c extension module staticly with python
interpreter. But in my c extension module, I have external variable
declaration, which makes it fail to be linked with Python interpreter.
There must be some way to solve this, could anybody help me with this?

Thank you very much.

Xiaohong Yuan


--
http://www.python.org/mailman/listinfo/python-list
ask help for problem with static linking (fwd) [ In reply to ]
Xiaohong Yuan wrote:

> I am trying to link my c extension module staticly with python
> interpreter. But in my c extension module, I have external variable
> declaration, which makes it fail to be linked with Python
> interpreter. There must be some way to solve this, could anybody
> help me with this?

Please forgive the lack of response to your query, but I think people
are confused about what you are asking.

A variable declared as "extern" will have to be found in some object
when you link. Is this variable something you expected the Python
interpreter to expose? If so, what is it? What version of Python?
What platform? What compiler?

- Gordon
ask help for problem with static linking (fwd) [ In reply to ]
On Fri, 4 Jun 1999, Gordon McMillan wrote:

> Xiaohong Yuan wrote:
>
> > I am trying to link my c extension module staticly with python
> > interpreter. But in my c extension module, I have external variable
> > declaration, which makes it fail to be linked with Python
> > interpreter. There must be some way to solve this, could anybody
> > help me with this?
>
> Please forgive the lack of response to your query, but I think people
> are confused about what you are asking.
>
> A variable declared as "extern" will have to be found in some object
> when you link. Is this variable something you expected the Python
> interpreter to expose? If so, what is it? What version of Python?
> What platform? What compiler?
>
> - Gordon
>

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
ask help for problem with static linking (fwd) [ In reply to ]
Xiaohong Yuan wrote:
[snip]
> 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
used
to share information between your extension and your main program. If
this
is the case syou have two options:

1) redesign your extension so that the information shared by your
external
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
components
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@cloud9.net | http://www.cloud9.net/~proteus
-----------------------------------------------------------------------------
If you are not willing to control your own mind, there are plenty of
other
people who are willing to do it for you.
=============================================================================