This change is in the CVS repository for the R3.14 branch and the CVS
head.
On Mar 23, 2009, at 3:05 PM, Bill Lavender wrote:
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
--
Eric Norum <[email protected]>
Advanced Photon Source
Argonne National Laboratory
(630) 252-4793
- Replies:
- Re: environ symbol on MacOS X with EPICS base 3.14.10 Bill Lavender
- References:
- environ symbol on MacOS X with EPICS base 3.14.10 Bill Lavender
- Navigate by Date:
- Prev:
Re: Motor problems(RBV can't update itself) Ron Sluiter
- Next:
Re: environ symbol on MacOS X with EPICS base 3.14.10 Bill Lavender
- 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:
environ symbol on MacOS X with EPICS base 3.14.10 Bill Lavender
- Next:
Re: environ symbol on MacOS X with EPICS base 3.14.10 Bill Lavender
- 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
|