Issue119

Title ld: Undefined symbols: _environ
Priority bug Status chatting
Superseder Nosy List baagaard, knepley, leif, willic3
Assigned To leif Topics Build, PyLith

Created on 2007-06-22.20:10:03 by leif, last changed 2007-06-29.01:22:36 by leif.

Files
File name Uploaded Type Edit
unnamed leif, 2007-06-22.20:10:01 text/html
unnamed leif, 2007-06-22.20:20:01 text/html
unnamed leif, 2007-06-22.20:25:01 text/html
Messages
msg385 (view) Author: leif Date: 2007-06-29.01:22:36
My next attempt at a fix:

spatialdata: r7557
PyLith: r7558

Conditionally add Python libs to the link line, under the assumption that
libpython might be static or broken.
msg382 (view) Author: baagaard Date: 2007-06-22.21:13:17
On my Mac, I looked at what it was in r7307 to spatialdata that messes up my
modules. It appears that it is not just -no-undefined but also trying to link
against the Python libraries when building the modules and library. I verified
that it links against the Python version that attempts to load the modules. The
only solution that seems to work is to remove the -no-undefined AND Python
libraries.
msg381 (view) Author: leif Date: 2007-06-22.21:03:56
My trial solution to this is to conditionally add "-no-undefined":

AC_PROG_LIBTOOL
if test "$allow_undefined_flag" = unsupported; then
    AM_LDFLAGS="-no-undefined $AM_LDFLAGS"
fi

spatialdata: r7388
PyLith: r7391

This means "-no-undefined" will only be used on Windows.

This whole ordeal leaves me speechless. In 2007, building shared libs portably
is still a big deal...
msg380 (view) Author: leif Date: 2007-06-22.20:45:01
-------- Original Message --------
Subject: 	Re: error when trying to run pytests
Date: 	Thu, 21 Jun 2007 20:48:18 -0700
From: 	Brad Aagaard <baagaard@usgs.gov>
To: 	Leif Strand <leif@geodynamics.org>
CC: 	Charles Williams <willic3@rpi.edu>, knepley@mcs.anl.gov
References: 	<200706220221.l5M2LPB5022157@smtp7.server.rpi.edu> 
<467B36CB.2060300@usgs.gov> <467B3B0D.1090806@geodynamics.org>

Leif-

I seem to build okay, but now when I try to run the pytests I get

make[1]: Nothing to be done for 
`/Users/brad/src/cig/spatialdata/tests/pytests/geocoords/testgeocoords.py'.
make  check-TESTS
test_initialize (TestCSCart.TestCSCart) ... Fatal Python error: 
Interpreter not initialized (version mismatch?)
FAIL: testgeocoords.py

It looks like your changes to cit_python.m4 are telling the linking to 
use the framework Python but I have Python elsewhere. configure knows 
where my Python is, so can't cit_python detect that I am not using the 
framework Python?

Brad
msg379 (view) Author: leif Date: 2007-06-22.20:40:02
-------- Original Message --------
Subject: 	Re: Building PyLith on a Mac
Date: 	Thu, 21 Jun 2007 20:21:48 -0700
From: 	Brad Aagaard <baagaard@usgs.gov>
To: 	Leif Strand <leif@geodynamics.org>
CC: 	Charles Williams <willic3@rpi.edu>, knepley@mcs.anl.gov
References: 	<200706220221.l5M2LPB5022157@smtp7.server.rpi.edu> 
<467B36CB.2060300@usgs.gov> <467B3B0D.1090806@geodynamics.org>

Leif-

I have Fink gfortran and gcc installed which aren't compatible with 
Apple Python. Apple gcc doesn't include gfortran.

I patched the posixmodule.c file in Python and now the module that 
failed links without errors, so I think I am good.

Brad

Leif Strand wrote:
> Guys,
> 
> I'm guessing I don't see this because I'm using Apple's Python, instead 
> of Fink's.
> 
> This is the most informative thing I found:
> 
>    http://lists.apple.com/archives/xcode-users/2004/Jan/msg00230.html
> 
>  From this, I gather that shared objects should use *_NSGetEnviron(), or 
> you can kludge your way around it by allowing unresolved symbols.
> 
> Brad, that is the informative error output I was looking for. 
> ("-Wl,-Y,nnn" is supposed to tell you where the unresolved symbols are 
> coming from; heaven only knows why that isn't the default). It looks 
> like your 'libpython' is static instead of shared, which might be 
> related... or not:
> 
> p-wave:/sw/lib/python2.3/config buildbot$ nm -A libpython2.3.* | grep 
> environ
> libpython2.3.a:posixmodule.o: 0000b1dc b _environ
> libpython2.3.dylib:posixmodule.o: 00114790 b _environ
> p-wave:/sw/lib/python2.3/config buildbot$
> 
> 
> Maybe this is a Fink bug. By contrast:
> 
> p-wave:/System/Library/Frameworks/Python.framework buildbot$ nm -A 
> Python | grep environ
> p-wave:/System/Library/Frameworks/Python.framework buildbot$ nm -A 
> Python | grep NSGetEnviron
> Python:posixmodule.o:          U __NSGetEnviron
> p-wave:/System/Library/Frameworks/Python.framework buildbot$
> 
> 
> Can you guys use Apple's python for now?
> 
> --Leif
> 
> 
> Brad Aagaard wrote:
>> Leif-
>>
>> I did this when _environ showed up as an undefined symbol in one of 
>> the spatialdata modules and get:
>>
>> /sw/tools/python-2.5/gcc-4.0/lib/python2.5/config/libpython2.5.a(posixmodule.o) 
>> reference to undefined _environ
>>
>> So I should patch posixmodule.o using the fix that Charles noted in 
>> python2.5 and rebuild python?
>>
>> Brad
>>
>
msg378 (view) Author: leif Date: 2007-06-22.20:25:01
-------- Original Message --------
Subject: 	Re: Building PyLith on a Mac
Date: 	Thu, 21 Jun 2007 19:41:15 -0700
From: 	Brad Aagaard <baagaard@usgs.gov>
To: 	Charles Williams <willic3@rpi.edu>
CC: 	leif@geodynamics.org, knepley@mcs.anl.gov
References: 	<200706220221.l5M2LPB5022157@smtp7.server.rpi.edu>

Leif-

I did this when _environ showed up as an undefined symbol in one of the 
spatialdata modules and get:

/sw/tools/python-2.5/gcc-4.0/lib/python2.5/config/libpython2.5.a(posixmodule.o) 
reference to undefined _environ

So I should patch posixmodule.o using the fix that Charles noted in 
python2.5 and rebuild python?

Brad
msg377 (view) Author: leif Date: 2007-06-22.20:20:01
-------- Original Message --------
Subject: 	Building PyLith on a Mac
Date: 	Thu, 21 Jun 2007 22:21:25 -0400
From: 	Charles Williams <willic3@rpi.edu>
Reply-To: 	Charles Williams <willic3@rpi.edu>
Organization: 	RPI
To: 	leif@geodynamics.org
CC: 	baagaard@usgs.gov, knepley@mcs.anl.gov

Hi Leif, 
I tried the linker option you sent to Brad, but the output didn't seem
any more informative.  The 
command I executed was:

mpicxx  -o .libs/bcmodule.so -bundle  .libs/bc.o .libs/bc_embed.o
-L/usr/local/
lib -L/Users/willic3/geoframe/export/debug/lib -L/sw/lib
../../libsrc/.libs/libp
ylith.dylib /usr/local/lib/libproj.dylib
-L/Users/willic3/geoframe/export/pythia
-0.8-debug/lib
-L/Users/willic3/geoframe/tools/petsc-dev/darwin8.x-openmpi-debug
/lib -L/usr/X11R6/lib /usr/local/lib/libparmetis.dylib
/usr/local/lib/libmetis.d
ylib -L/Users/willic3/geoframe/tools/openmpi-debug/lib
-L/usr/lib/gcc/i686-apple
-darwin8/4.0.1 -L/usr/lib/gcc/i686-apple-darwin8/4.0.1/../../..
-L/sw/bin/../lib
/gcc-lib/i386-apple-darwin8/4.0.3/
-L/sw/bin/../lib/gcc-lib/i386-apple-darwin8/4
.0.3 -L/Users/willic3/geoframe/export/debug/lib//
-L/sw/lib/gcc-lib/i386-apple-d
arwin8/4.0.3/ -L/usr/lib/gcc//
-L/sw/bin/../lib/gcc-lib/i386-apple-darwin8/4.0.3
/// -L/sw/lib/gcc-lib/i386-apple-darwin8/4.0.3/// -L/usr/lib//
-L/sw/lib/python2
.5/config /Users/willic3/geoframe/export/debug/lib/libspatialdata.dylib
-lpetsct
s -lpetscsnes -lpetscksp -lpetscdm -lpetscmat -lpetscvec -lpetsc -lX11
-lcmumps 
-ldmumps -lsmumps -lzmumps -lpord -lscalapack -lblacs -lchaco -lparmetis
-lmetis
 -lPLAPACK -lsuperlu_dist_2.0 -ltetgen -llapack -lblas -lmpi_f90 -lf95
-lm -lgcc
_eh -lSystemStubs -lmx
/Users/willic3/geoframe/tools/openmpi-debug/lib/libmpi_cx
x.dylib -lstdc++
/Users/willic3/geoframe/tools/openmpi-debug/lib/libmpi.dylib /u
sr/lib/gcc/i686-apple-darwin8/4.0.1/../../../libdl.dylib
/Users/willic3/geoframe
/tools/openmpi-debug/lib/liborte.dylib
/Users/willic3/geoframe/tools/openmpi-deb
ug/lib/libopal.dylib -lgcc_s.10.4 -lSystem -lpython2.5 -ldl
/sw/lib/libnetcdf_c+
+.dylib /sw/lib/libnetcdf.dylib -march=nocona -Wl,-Y,10

I executed it from:

/Users/willic3/geoframe/build/debug/pylith-1.0/modulesrc/bc

pylith-1.0 is my build directory.  The output I got was:

/usr/bin/ld: warning -L: directory name
(/Users/willic3/geoframe/export/pythia-0.8-debug/lib) 
does not exist
/usr/bin/ld: Undefined symbols:
_environ
collect2: ld returned 1 exit status

The missing directory name is unimportant, and the information does not
seem any different than 
before.  It appears that the missing _environ symbol is a common problem
on Darwin, and the 
two possible solutions are:

1.  Allow undefined symbols (-undefined dynamic_lookup).
2.  Define the symbol (I think this is described on the fink Wiki page).

What do you think we should do to get this working?  Right now, Brad and
I are editing our 
Makefile.am files to remove the -no-undefined flag, but this is obviously 
not a real solution.

Thanks,
Charles

Charles Williams
Dept. of Earth & Environmental Science
Science Center, 2C01B
Rensselaer Polytechnic Institute
Troy, NY  12180
phone:   (518) 276-3369
FAX:     (518) 276-2012
e-mail:  willic3@rpi.edu
msg376 (view) Author: leif Date: 2007-06-22.20:10:01
-------- Original Message --------
Subject: 	Re: problem linkin libpylith on Darwin
Date: 	Thu, 21 Jun 2007 11:44:10 -0700
From: 	Leif Strand <leif@geodynamics.org>
To: 	Brad Aagaard <baagaard@usgs.gov>
References: 	<467A00A2.8030504@usgs.gov>

Brad,

Copy & paste the link line into your terminal -- to run it by hand -- 
but add:

   -Wl,-Y,10

This will make the error message more informative. Be sure to uncomment 
my LDFLAGS.

--Leif

Brad Aagaard wrote:
> Leif-
>
> I can almost build libpylith on my Mac with your Makefile settings. I 
> am left with
>
> ld: Undefined symbols:
> _environ
>
> This seems to be a Fink related issue:
>
> http://wiki.finkproject.org/index.php/Fink:Porting_Notes
>
> I don't find this symbol referenced in any of the PyLith .o files, so 
> I am not sure where it is coming from and how to resolve it. Any ideas?
>
> Brad
History
Date User Action Args
2007-06-29 01:22:36leifsetnosy: leif, baagaard, willic3, knepley
messages: + msg385
2007-06-22 21:13:17baagaardsetnosy: leif, baagaard, willic3, knepley
messages: + msg382
2007-06-22 21:03:56leifsetpriority: bug
topic: + Build, PyLith
assignedto: leif
messages: + msg381
nosy: + baagaard, knepley, willic3
2007-06-22 20:45:01leifsetmessages: + msg380
2007-06-22 20:40:02leifsetmessages: + msg379
2007-06-22 20:25:01leifsetfiles: + unnamed
messages: + msg378
2007-06-22 20:20:02leifsetfiles: + unnamed
status: unread -> chatting
messages: + msg377
2007-06-22 20:10:03leifcreate