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