X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-1.4 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED,RP_MATCHES_RCVD,SPF_HELO_PASS,TW_QL,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org To: cygwin AT cygwin DOT com From: Ted Byers Subject: Re: How do I run a program compiled in cygwin from a program that is running in a Windows CMD shell? Date: Thu, 15 Sep 2011 13:17:04 +0000 (UTC) Lines: 69 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit User-Agent: Loom/3.14 (http://gmane.org/) X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com 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/test.cygwin.perl.pl 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 Ted -- 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