<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>pnotepad.org forums Topic: g++ tool for Cygwin?</title>
		<link>http://pnotepad.org/forums/topic/175</link>
		<description>Programmer&#039;s Notepad Forums</description>
		<language>en-US</language>
		<pubDate>Thu, 09 Sep 2010 12:49:30 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.1</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://pnotepad.org/forums/search.php</link>
		</textInput>
		<atom:link href="http://pnotepad.org/forums/rss/topic/175" rel="self" type="application/rss+xml" />

		<item>
			<title>g++ tool for Cygwin? (MurphyMc)</title>
			<link>http://pnotepad.org/forums/topic/175#post-645</link>
			<pubDate>Mon, 12 Mar 2007 23:13:55 +0000</pubDate>
			<dc:creator>MurphyMc</dc:creator>
			<guid isPermaLink="false">645@http://pnotepad.org/forums/</guid>
			<description>&#60;p&#62;Wow, glad you figured it out, DubHunt.  That could have been tricky.&#60;/p&#62;
&#60;p&#62;And thanks, Simon.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>g++ tool for Cygwin? (DubHunt)</title>
			<link>http://pnotepad.org/forums/topic/175#post-644</link>
			<pubDate>Sun, 11 Mar 2007 23:25:58 +0000</pubDate>
			<dc:creator>DubHunt</dc:creator>
			<guid isPermaLink="false">644@http://pnotepad.org/forums/</guid>
			<description>&#60;p&#62;Got it! I created and saved the file in PN, but I had Tools&#38;gt;Line Endings&#38;gt;Windows (CRLF) checked. I changed it to Unix (LF), saved, and everything worked fine. This was also the reason why I was getting an Unexpected End of File error from my .bash_profile when I ran Cygwin.&#60;br /&#62;
You learn something new every day.&#60;br /&#62;
Thanks for the help.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>g++ tool for Cygwin? (MurphyMc)</title>
			<link>http://pnotepad.org/forums/topic/175#post-642</link>
			<pubDate>Sun, 11 Mar 2007 22:07:33 +0000</pubDate>
			<dc:creator>MurphyMc</dc:creator>
			<guid isPermaLink="false">642@http://pnotepad.org/forums/</guid>
			<description>&#60;p&#62;Is there, indeed, a line break between the &#34;/home/Anthony/&#34; and the &#34;: No such file or directory&#34;?&#60;/p&#62;
&#60;p&#62;If so, the problem would appear to be that it's trying to cd into the directory &#34;/home/Anthony/&#38;lt;newline&#38;gt;&#34;.  My best guess as to why this is happening is that there is some small problem with your Tool setup or the run.sh script.  If you want to copy/paste yours, maybe I can spot it...
&#60;/p&#62;</description>
		</item>
		<item>
			<title>g++ tool for Cygwin? (DubHunt)</title>
			<link>http://pnotepad.org/forums/topic/175#post-641</link>
			<pubDate>Sun, 11 Mar 2007 21:43:53 +0000</pubDate>
			<dc:creator>DubHunt</dc:creator>
			<guid isPermaLink="false">641@http://pnotepad.org/forums/</guid>
			<description>&#60;p&#62;Thanks for the help. I see how I can use the script and tool to run the output as well. It compiles cpp files in my home directory, however, I do get an error: &#60;/p&#62;
&#60;p&#62;/bin/run.sh: line 4: cd: /home/Anthony/&#60;br /&#62;
: No such file or directory&#60;/p&#62;
&#60;p&#62;I don't know why it would not be able to find the directory. If I run&#60;br /&#62;
bash --login -i&#60;br /&#62;
from cmd.exe and then type&#60;br /&#62;
cd /home/Anthony/&#60;br /&#62;
it changes dir to my home directory (which it is already in). Any idea what's going on?&#60;br /&#62;
(I am very new to cygwin/bash)
&#60;/p&#62;</description>
		</item>
		<item>
			<title>g++ tool for Cygwin? (simon)</title>
			<link>http://pnotepad.org/forums/topic/175#post-640</link>
			<pubDate>Sun, 11 Mar 2007 20:25:58 +0000</pubDate>
			<dc:creator>simon</dc:creator>
			<guid isPermaLink="false">640@http://pnotepad.org/forums/</guid>
			<description>&#60;p&#62;Awesome Explanation!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>g++ tool for Cygwin? (MurphyMc)</title>
			<link>http://pnotepad.org/forums/topic/175#post-639</link>
			<pubDate>Sun, 11 Mar 2007 16:49:39 +0000</pubDate>
			<dc:creator>MurphyMc</dc:creator>
			<guid isPermaLink="false">639@http://pnotepad.org/forums/</guid>
			<description>&#60;p&#62;No, the Tools command is not for cmd.exe.  It just runs the command.  You could run a cygwin program as a tool.  For example, put &#34;c:\cygwin\bin\ls.exe&#34; as the tool command and run it and you'll get a directory listing in the output window.&#60;/p&#62;
&#60;p&#62;But you'll run into a couple of problems.  Specifically, Windows paths (&#34;C:\documents and settings\...&#34;) won't work with most cygwin tools, and lots of cygwin tools will require various environment variables to be set, which won't be set in this context (except maybe if you started PN from a bash prompt or some such).&#60;/p&#62;
&#60;p&#62;With a bit of creativity, these shouldn't be showstoppers, though.&#60;/p&#62;
&#60;p&#62;To confront the first issue, you can take advantage of the &#34;cygpath&#34; tool which comes with Cygwin.  It can convert back and forth between Windows style paths and unix style paths.&#60;/p&#62;
&#60;p&#62;The easiest way to confront the second problem is probably by invoking a bash login shell, which will set up the environment, and then having your Cygwin tools run from within there.&#60;/p&#62;
&#60;p&#62;Let's do an example, shall we?&#60;/p&#62;
&#60;p&#62;Say we want a tool which will invoke g++ on the file in the editor.  If the file is named helloworld.cpp, we want the output file to be helloworld.exe.&#60;/p&#62;
&#60;p&#62;To do this, we want to run bash and then have bash enter the directory that helloworld.cpp is in (this is easiest) and then run g++ helloworld.cpp -o helloworld.exe.&#60;/p&#62;
&#60;p&#62;So let's create a little helper shell script in your cygwin home directory.  Create a file called run.sh and put the following in it:&#60;br /&#62;
#!/bin/bash&#60;br /&#62;
declare p=$(cygpath -u &#34;$1&#34;)&#60;br /&#62;
cd &#34;$p&#34;&#60;br /&#62;
$2 $3 $4 $5 $6 $7 $8 $9&#60;/p&#62;
&#60;p&#62;Then add the Tool to PN:&#60;br /&#62;
Call it g++.&#60;br /&#62;
For the command, enter: c:\cygwin\bin\bash.exe&#60;br /&#62;
For parameters, enter: --login run.sh &#34;%d\&#34; g++ &#34;%f&#34; -o &#34;%n.exe&#34;&#60;/p&#62;
&#60;p&#62;If you look at what this does...&#60;/p&#62;
&#60;ol&#62;
&#60;li&#62;the Tool runs bash.exe --login run.sh ...
&#60;/li&#62;
&#60;li&#62;bash sets up the environment (--login) and then invokes run.sh with the positional arguments ($1, $2, etc.) as:
&#60;ol&#62;
&#60;li&#62;the directory name of the file in the editor (%d)
  &#60;/li&#62;
&#60;li&#62;g++
  &#60;/li&#62;
&#60;li&#62;the filename of the file in the editor (helloworld.cpp) (%f)
  &#60;/li&#62;
&#60;li&#62;-o
  &#60;/li&#62;
&#60;li&#62;the file title+.exe (helloworld.exe) (%n.exe)
  &#60;/li&#62;
&#60;/ol&#62;
&#60;/li&#62;
&#60;li&#62;Now run.sh...
&#60;/li&#62;
&#60;li&#62;uses cygpath to convert the first positional argument into a unix-style path
&#60;/li&#62;
&#60;li&#62;changes to that directory
&#60;/li&#62;
&#60;li&#62;takes the rest of the parameters (in this case &#34;g++ helloworld.cpp -o helloworld.exe&#34;) and runs them as a command
&#60;/li&#62;
&#60;/ol&#62;
&#60;p&#62;Note that the file and directory names are put in quotes since they may contain spaces.&#60;br /&#62;
Also note a little hack: the directory name (%d) is followed by another backslash.  This is because %d expands into the directory name followed by a backslash, which would then &#34;escape&#34; the following doublequote when the commandline is parsed.  So this way you actually have the directory end up with a trailing double backslash, which then cygpath converts to a double trailing forward slash, i.e. &#34;/cygdrive/c/documents and settings/user/desktop//&#34;.  Fortunately, this doesn't cause a problem.&#60;/p&#62;
&#60;p&#62;Hope this helps.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>g++ tool for Cygwin? (DubHunt)</title>
			<link>http://pnotepad.org/forums/topic/175#post-630</link>
			<pubDate>Wed, 07 Mar 2007 08:19:47 +0000</pubDate>
			<dc:creator>DubHunt</dc:creator>
			<guid isPermaLink="false">630@http://pnotepad.org/forums/</guid>
			<description>&#60;p&#62;Ok, I've been using PN for a while, mostly for Java. I have a javac and java tool set up. What I need is something similar for running g++ via Cygwin, and the resulting .out file. The tools command is for cmd.exe, right? I guess I need a way to start cygwin from cmd.exe, then execute commands within it. Is this possible?&#60;/p&#62;
&#60;p&#62;Thanks,&#60;br /&#62;
Dub
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
