John W. Eaton wrote:
> I'm using the glob module in GNU Octave and a Windows user complained
> that linking failed with an undefined reference to getlogin.

You mean getlogin or getlogin_r?

> The problem appears to be that getlogin_r is called from glob, and the
> gnulib replacement for getlogin_r calls getlogin unconditionally, but
> getlogin doesn't exist on Windows systems.

Looking at the code in lib/glob.c, you see that getlogin_r is not supposed
to be invoked on native Windows platforms (e.g. mingw and MSVC builds):

#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
# define WINDOWS32
#endif

...

#  ifdef WINDOWS32
          /* Windows NT defines HOMEDRIVE and HOMEPATH.  But give preference
             to HOME, because the user can change HOME.  */
...
#  else
...
              success = getlogin_r (name, buflen) == 0;
#  endif

So something must be wrong with the build environment of your user.

> What would be the preferred way of fixing this problem?  Should there
> be a separate getlogin module?

No. Who wants getlogin, when getlogin_r is a better interface?

And the glob function does not need the user's name, but his home
directory.

Bruno


Reply via email to