The Samba-Bugzilla – Bug 5412
Build system: Compile failing with 'Undefined symbols: "_environ", referenced from: _environ$non_lazy_ptr in heimdal_roken.o'
Last modified: 2008-10-27 18:57:10 UTC
This was when compiling "4.0.0alpha3-GIT-1d940e4" on OSX:
Samba will be compiled with flags:
CPP = gcc -E
CPPFLAGS = -I./include -I. -I./lib -I./lib/replace -I./lib/talloc -D_SAMBA_BUILD_=4 -DHAVE_CONFIG_H
CC = gcc
PICFLAG = -fno-common
BNLD = gcc
STLD = /usr/bin/ar
STLD_FLAGS = -rcs
SHLD = gcc
SHLD_FLAGS = -dynamiclib -Wl,-search_paths_first -undefined error
MDLD = gcc
MDLD_FLAGS = -dynamiclib -Wl,-search_paths_first -undefined dynamic_lookup
SHLIBEXT = dylib
srcdir = .
builddir = .
pwd = /Users/andrew/Development/Samba/source
"_environ", referenced from:
_environ$non_lazy_ptr in heimdal_roken.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [bin/shared/libdcerpc.dylib] Error 1
From what I can tell _environ$non_lazy_ptr is a OSX specific symbol.
Here is an excerpt from the OSX environ(7) man page that should explain this
Programs can query and modify the environment, using the environment rou-tines routines
tines getenv(3), putenv(3), setenv(3) and unsetenv(3). Direct access can
be made through the global variable environ, though it is recommended
that changes to the enviroment still be made through the environment rou-tines. routines.
Shared libraries and bundles don't have direct access to environ, which
is only available to the loader ld(1) when a complete program is being
linked. The environment routines can still be used, but if direct access
to environ is needed, the _NSGetEnviron() routine, defined in
<crt_externs.h>, can be used to retrieve the address of environ at run-time. runtime.
And here is a patch that fixes the failure:
diff --git a/source/heimdal/lib/roken/roken.h.in b/source/heimdal/lib/roken/roken.h.in
index 82473d7..a3408f2 100644
@@ -445,8 +445,13 @@ extern int opterr;
+#define environ (*_NSGetEnviron())
extern char **environ;
We've now a new version of HEIMDAHL Kerberos in the source tree. Please retest if the problem persists!
So I'm going to close this for now. If the problem persits, reopen!
The build farm shows this is still a problem on MacOS, so probably BSD too. Please leave this open.
That's now up to Jelmer.
Ok, we can't fix this until we have access to a MacOS X installation. If someone has some interest to look into this, we would be glad :-) !
Fixed in aafe9ca1aa829f64d4bad1df3ee1d5997fb17d71