Frank Heckenbach wrote:
Adriaan van Os wrote:
While trying to build a Mach-O dynamically linked shared library with GPC and LD, I get the following error:
As a work-around try replacing the set operations in EnvVarChars and FileNameSpecialChars in p/rts/filename.pas and p/rts/gpc.pas by their values.
Thanks, the work around removes the common symbol problem and gets me one step further:
[G4:~] adriaan% ld -L$LibPath /usr/lib/dylib1.o usummer.o -dylib -lgpc -lgcc -lSystem ld: Undefined symbols: _environ
I have looked around for the _environ symbol and found it in rts.c. The // comments show how I worked around the problem to build the dynamically linked shared library. But it is a hack and there will probably be a better way.
#if defined (HAVE_ENVIRON) || defined (environ) #if !defined (environ) && !defined (ENVIRON_DECLARED) // extern char **environ; #endif #elif defined (HAVE___ENVIRON) || defined (__environ) #if !defined (__environ) && !defined (__ENVIRON_DECLARED) // extern char **__environ; #endif #define environ __environ #endif
GLOBAL (PCStrings _p_GetStartEnvironment (PCStrings ValueIfNotFound UNUSED)) { // #if defined (HAVE_ENVIRON) || defined (environ) // return environ; // #else return ValueIfNotFound; // #endif }
On Mac OS X, rts-config.h reads as follows:
/* Define if you have an environ variable. */ #define HAVE_ENVIRON 1
/* Define if you have an __environ variable. */ /* #undef HAVE___ENVIRON */
/* Define if the environ variable is declared in <unistd.h>. */ /* #undef ENVIRON_DECLARED */
/* Define if the __environ variable is declared in <unistd.h>. */ /* #undef __ENVIRON_DECLARED */
Regards,
Adriaan van Os