Mail Archives: cygwin/1999/04/28/11:14:23
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 -