delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2012/03/07/09:56:23

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Date: Wed, 7 Mar 2012 15:55:27 +0100
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: Oracle OCI under cygwin
Message-ID: <20120307145527.GI5159@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <6BFA9AF2C7556E42AFF3F187ECAB07B802DAF981 AT bespdc01 DOT mediaxim DOT local> <20120307144649 DOT GH5159 AT calimero DOT vinschen DOT de>
MIME-Version: 1.0
In-Reply-To: <20120307144649.GH5159@calimero.vinschen.de>
User-Agent: Mutt/1.5.21 (2010-09-15)
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

On Mar  7 15:46, Corinna Vinschen wrote:
> On Mar  7 14:38, Michel Bardiaux wrote:
> > I have an up-to-date cygwin on XP SP3 (and yes, rebasealled). I have
> > also installed the Oracle basic (NOT instant) client for Win32. And I
> > have a C application that queries an Oracle DB using OCI. Another
> > relevant bit of setup info: environment variable TNS_ADMIN =
> > \\besprd01\techdoc\database\oracle\OracleNet_WinClient (set in XP
> > Control Panel).
> > 
> > Now, when compiled with MS Visual Studio 2010 Express, and run from a
> > DOS (sic) box, the app works fine, which proves both the app and the
> > setup are basically fine. Ditto when run from a Cygwin mintty.
> > 
> > But if I compile my app with cygwin, and run it in mintty (of course), I
> > get an error message meaning essentially that OCILogon failed because it
> > did not find an Oracle config file called tnsnames.ora that is supposed
> > to be in $TNS_ADMIN.
> > 
> > Strace gives no clue - because the app WORKS when run by strace! The
> > Win32 PROCMON shows that tnsnames.ora is looked for in %TNS_ADMIN% for
> > the pure win32 app, but in the local directory for the cygwin app.
> > Indeed, if I kluge my code in the cygwin case to temporarily chdir to
> > $TNS_ADMIN (rewritten as a cygwin path of course) just before calling
> > OCILogon, it works.
> 
> Cygwin applications don't use the WIN32 environment.  Rather they have
> their own copy of the environment in a POSIX layout.  What happens is
> probably that the OCI lib calls GetEnvironmentString ("TNS_ADMIN",...)
> and gets nothing back, since the variable is just not in the Win32
> environment of the Cygwin application.
> 
> The workaround is to do this before calling ani OCI lib function:
> 
>   #include <sys/cygwin.h>
> 
>   cygwin_internal (CW_SYNC_WINENV);
> 
> This call copies the POSIX environment over to the Win32 environment
> correctly in 

Hups, there has something gone wrong.  Let me try again:

  This call copies the POSIX environment over to the Win32 environment
  of the calling process, so the OCI lib functions should find the
  TNS_ADMIN variable when called *after* the above call.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


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