X-Recipient: archive-cygwin@delorie.com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:message-id:date:from:mime-version:to:subject
	:content-type:content-transfer-encoding; q=dns; s=default; b=vtb
	v46ORHeBrKNrKkObYKeWhZJUi4YsvJMxcE2Zy9fQIDIkrNs8NDsI0t7DlzEqblyF
	7FY0fiszRacKpqLPUOAxu9rUFFjlgnSCgDNam7YIJNWYDsdzUhj6wzpFDPCiT8bJ
	fIBe0Hi/Qy2WiBErq/74wklVRtgHWtJ7p0mOQQxA=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:message-id:date:from:mime-version:to:subject
	:content-type:content-transfer-encoding; s=default; bh=NfMb+k6aA
	kVVfpkA85TPK7DFk0c=; b=PtDHaWYXK1841wyNaDSBK9YejC3syjCvn3YbbHBUU
	iDWXD+ZPH9ojt6lCMxOwpNptDQlhpgqGj6RF9/zxzaQDwjM9wU1l2h8L3qoOCu2H
	19qXjrKLV7oWTAJNj+QiYBi5yvzXab7bErPHRJuBWYtmfh206fqg6g6vAm0K9T9T
	cQ=
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=ham version=3.3.2
X-HELO: bubo.tul.cz
Message-ID: <53DA228D.7000808@tul.cz>
Date: Thu, 31 Jul 2014 13:03:41 +0200
From: Jan Brezina <jan.brezina@tul.cz>
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0
MIME-Version: 1.0
To: cygwin@cygwin.com
Subject: getcwd and PATH problem with moved cygwin1.dll
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-IsSubscribed: yes


Hi,

trying to make standalone build of an application with embedded Python I 
observe wrong values returned by getcwd and getenv("PATH") calls when 
cygwin1.dll is in the same directory as the executable. Python use these 
two calls to get absolute path of the
executable (argv[0]) and to determine python prefix relative to it.

Test source 'py_hallo.cc'
====
#include <iostream>
#include <string>
#include <unistd.h>
#include <stdlib.h>

using namespace std;
#define MAXPATHLEN 256

int main(int argc, char ** argv) {
     char *path = getenv("PATH");
     cout << "env PATH: " << path << endl;

     char buff[MAXPATHLEN];
     char *cwd =getcwd(buff, MAXPATHLEN);
     cout << "cwd: " << cwd << endl;
}
===
makefile:
===
all:
     g++ -o py_hallo py_hallo.cc

.PHONY: package
package:
     rm -rf package
     mkdir package
     mkdir package/bin
     cp py_hallo.exe package/bin
     cp `cygcheck.exe ./py_hallo.exe | grep ".*\cyg.*.dll"` package/bin
===

after
work_dir> make
work_dir> make package

I get prototype of installation in work_dir/package
Running py_hallo.exe within package directory yields wrong results when 
running from
windows command prompt:

work_dir>set PATH=C:\cygwin\bin:C:\...\work_dir\package\bin

work_dir\package\bin>py_hallo.exe
env PATH: /cygdrive/c/cygwin/bin:/usr/bin
cwd: /usr/bin

work_dir\package>bin\py_hallo.exe
env PATH: /cygdrive/c/cygwin/bin:/usr/bin
cwd: /

Outside of work_dir/package, getcwd works well, but PATH is still 
screwed up:

work_dir>work_dir\package\py_hallo.exe
env PATH: /cygdrive/c/cygwin/bin:/usr/bin
cwd: /cygwindrive/c/cygwin/home/jb/work_dir

-----------------------------

It seems that cygwin substitutes location of cygwin1.dll by its standard 
location
in the PATH variable.
Can someone explain wats going on there? Is it bug or unsupported usage 
(moving cygwin1.dll)?
According to the Google, this is what people usually do to get 
standallone packages without installator since otherwise windows can not 
find DLLs.

Thank you for any help.

Jan Brezina




--
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

