This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project. See the Cygwin home page for more information.
Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

putenv does not put env into win32?


Consider following code, where lpszModuleName is //c/test/somedll.dll
which requires //c/test/anotherdll.dll to function.

       if(pathvar = getenv("PATH")) {
            char * dir = alloca(strlen(lpszModuleName)+1);
            char * tmppath = alloca(strlen(dir)+strlen(pathvar)+1);
            strcpy(dir, lpszModuleName);
            dir = dirname(dir);
            strcpy(tmppath, "PATH=");
            strcat(tmppath, dir);
            /* this line is for future automatic recognition */
            strcat(tmppath, strstr(pathvar,"/") ? ":" : ";");
            strcat(tmppath, pathvar);
            putenv(tmppath);
        }
        WinModuleName = pathFromUnixToWin(lpszModuleName);
	hMod = LoadLibrary(WinModuleName);

The LoadLibrary fails in this case. If I compile the same code using
-mno-cygwin  changing putenv to _putenv (as told by msvc++ help),
replacing contents of lpszModuleName with c:\test\somedll.dll and
removing call to pathFromUnixToWin everything works fine.

Any ideas of how to call Win32 versions of getenv/_putenv instead of
cygwin ones?

Eugene.

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com