delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1999/04/28/11:14:23

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
Sender: cygwin-owner AT sourceware DOT cygnus DOT com
Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com
Message-Id: <199904281512.KAA25861@modi.xraylith.wisc.edu>
X-Authentication-Warning: modi.xraylith.wisc.edu: localhost.xraylith.wisc.edu [127.0.0.1] didn't use HELO protocol
To: Eugene Kanter <eugene AT bgs DOT com>
cc: cygwin AT sourceware DOT cygnus DOT com
Subject: Re: putenv does not put env into win32?
In-reply-to: Your message of "Wed, 28 Apr 1999 09:55:16 EDT."
<37271344 DOT 90F42BF5 AT bgs DOT com>
Date: Wed, 28 Apr 1999 10:12:39 -0500
From: Mumit Khan <khan AT xraylith DOT wisc DOT EDU>

Eugene Kanter <eugene AT bgs DOT com> writes:
> 
> cygwin
> 
> adding DIRDLL to the PATH (getenv/putenv) and calling
> LoadLibrary("DIRDLL/DLLA") (or dlopen("DIRDLL/DLLA",RTLD_NOW)) fails
> ONLY if current directory (chdir()) is not DIRDLL.

I can now confirm that adding to PATH in Cygwin process and then trying
to load a DLL using LoadLibrary doesn't work expected. dlopen works since
it explicitly searches in PATH for the library and uses LoadLibrary with
the complete pathname of the DLL.

Cygwin DLL doesn't seem to sync the environment variables with Win32
using SetEnvironment (or whatever it's called) in putenv(), and that's
the reason.

Please try the following untested code (note the explicit adding to win32 
env as well):

  int 
  add_path (const char *newdir)  
  {   
    char newpath[1024];  
  #if __CYGWIN__
    char scratch[1024];  
  #endif /* __CYGWIN__ */
    const char *pathvar = getenv ("PATH");  
    sprintf (newpath, "PATH=%s:%s", newdir, pathvar);  
    putenv (newpath);  
    printf ("New path: %s\n", newpath);  
      
  #if __CYGWIN__
    /* now do the win32 path. */  
    cygwin32_posix_to_win32_path_list (pathvar, scratch);  
    sprintf (newpath, "%s;%s", newdir, scratch);  
    SetEnvironmentVariable ("PATH", newpath);  
    printf ("New path: %s\n", newpath);  
  #endif /* __CYGWIN__ */
    return 0;  
  }

If this works, you can use something like it.

Regards,
Mumit


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019