How do I run a program compiled in cygwin from a program that is running in a Windows CMD shell?

Ted Byers
Thu Sep 15 14:22:00 GMT 2011

Thanks Marco and Andrew

I have actually been using Perl's back ticks and system (and not so much exec) 
for years, using Activestate perl, but this is the first time I tried to use 
them to run a program compiled using gcc within cygwin when I am running a 
perl program from Windows CMD console.

Here is a little perl script that invokes a program (qlt is a C++ program I 
wrote, and which I can compile using either MSVC++ or gcc):

	use strict;

	my $op = `./qlt.exe 6 2 2011 -1 10 12 2011 50 47 0.00 0.05 0.20`;

	print "$op\n";

If I compile qlt.exe using MSVC++, then it runs fine and produces the 
following output:

	Compilation started at Thu Sep 15 08:38:28

	C:/Perl64/bin\perl.exe -w c:/cygwin/home/Ted/Work/ 
	Valuation date =	February 6th, 2011
	Option type =		Put
	Maturity =		December 10th, 2011
	Underlying price =	50
	Strike =		47
	Risk-free int. rate =	5.00 %
	Dividend yield =	0.00 %
	Volatility =		20.00 %

	Option price :	1.5465
	Delta :		-0.25516
	Elasticity :	-8.2498
	Gamma :		0.035025
	Vega :		0.1473
	Theta :		-0.0028384
	Rho :		-0.12032
	Implied vol. :	20.00 %

	Compilation finished at Thu Sep 15 08:38:29

However, when I compile the program using gcc within cygwin (and run it the 
same way - Activestate perl from a Windows' CMD console, no output is 
produced, and if I try to run qlt from Windows' CMD, it complains about a 
missing DLL and dies..

So, I found a fix in terms of adding cygwin/bin to the  path.  That lets me 
run the programs I compile using gcc within cygwin's bash shell in the same 
way I run programs I compile using MSVC++.  The downside is that I was 
reluctant to make the cygwin programs themselves visible within Windows' CMD 
shell as I was concerned about the possibility that doing so might break some 
other Windows applications I use.

NB: this isn't a significant problem for this particular program (after all, I 
have both MSVC++ and gcc/cygwin), but I have a colleague that is sending me 
programs he developed on Ubuntu, and it would be a royal pain in the ass to 
refactor those in order to build them using MSVC++.  But the framework I 
developed to invoke all these programs (using Activestate perl CGI programs 
with Apache's httpd server, are not set up to run in cygwin (that, too, would 
be a royal pain to set up to run within cygwin, especially getting all the 
packages I use added alongside cygwin's perl).

Thanks again


Problem reports:
Unsubscribe info:

More information about the Cygwin mailing list