delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2014/07/31/07:04:16

X-Recipient: archive-cygwin AT delorie DOT 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 AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.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
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 DOT brezina AT tul DOT 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 AT cygwin DOT com
Subject: getcwd and PATH problem with moved cygwin1.dll
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

- Raw text -


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