I have encountered a minor problem with EPICS base 3.14.10 on MacOS X
systems that I would like to report. In my situation, I have a Python
module coded in C that invokes a library of mine, which in turn links
to the EPICS libCom and libca libraries. The symptom of the problem is
that when I try to import the Python module, I get an error like this:
ImportError: dlopen(./MpPrivate.so, 2): Symbol not found: _environ
Referenced from: /opt/epics/base-3.14.10/lib/darwin-x86/libCom.3.14.10.dylib
Expected in: flat namespace
This is on a computer running MacOS X 10.5 (Leopard).
The source of the problem is that MacOS X defines the symbol 'environ'
in some situations, but not all situations. I have found a variety of
forum posts and mailing list entries on the Internet that describe the
problem and how to fix it. The message
http://lists.apple.com/archives/xcode-users/2004/jan/msg00230.html
gives a particularly clear description of the issue and I quote part of
it here:
> _environ is defined in /usr/lib/crt1.o, which is only linked into
> executables. The corresponding file for dylibs (which frameworks use) is
> /usr/lib/dylib1.o and doesn't define _environ. Annoying as that is, it's
> correct because otherwise your library's _environ would be different from
> the _environ of the executable that loaded it.
>
> If you want to use _environ in a library on Mac OS X, you should use
> *_NSGetEnviron() instead. It's defined in /usr/include/crt_externs.h.
>
> Hope this helps,
> Eric
As far as I can tell, the only place in EPICS base that uses the 'environ'
symbol is the function epicsEnvShow() in "src/libCom/osi/os/default/osdEnv.c"
I have created a modified version of this function that looks like this
#if defined(__APPLE__)
# include <crt_externs.h>
# define environ (*_NSGetEnviron())
#endif
/*
* Show the value of the specified, or all, environment variables
*/
epicsShareFunc void epicsShareAPI epicsEnvShow (const char *name)
{
if (name == NULL) {
#if !defined(__APPLE__)
extern char **environ;
#endif
char **sp;
for (sp = environ ; (sp != NULL) && (*sp != NULL) ; sp++)
printf ("%s\n", *sp);
}
else {
const char *cp = getenv (name);
if (cp == NULL)
printf ("%s is not an environment variable.\n", name);
else
printf ("%s=%s\n", name, cp);
}
}
I haven't actually tested the modified version of the function, since I
do not use epicsEnvShow() for anything, but this change is enough to get
my Python module to load successfully without any missing symbols.
Hope this helps,
Bill Lavender
- Replies:
- Re: environ symbol on MacOS X with EPICS base 3.14.10 Eric Norum
- Navigate by Date:
- Prev:
RE: Motor problems(RBV can't update itself) Mark Rivers
- Next:
Re: Motor problems(RBV can't update itself) Ron Sluiter
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
<2009>
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
RE: MEDM Comm. Failure / STATE Richard Pastrick
- Next:
Re: environ symbol on MacOS X with EPICS base 3.14.10 Eric Norum
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
<2009>
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
|