<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>mingw &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://wordpress.com/tag/mingw/</link>
	<description>Feed of posts on WordPress.com tagged "mingw"</description>
	<pubDate>Wed, 08 Oct 2008 05:21:04 +0000</pubDate>

	<generator>http://wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[The GStreamer adventure part I: creating a Windows installer]]></title>
<link>http://codeanticode.wordpress.com/?p=41</link>
<pubDate>Fri, 12 Sep 2008 14:31:57 +0000</pubDate>
<dc:creator>codeanticode</dc:creator>
<guid>http://codeanticode.pl.wordpress.com/2008/09/12/the-gstreamer-adventure-part-i-creating-a-windows-installer/</guid>
<description><![CDATA[One main limitation when trying to use the GSVideo library for processing on windows was the relativ]]></description>
<content:encoded><![CDATA[<p>One main limitation when trying to use the <a href="http://users.design.ucla.edu/~acolubri/processing/gsvideo/home/index.html">GSVideo</a> library for processing on windows was the relatively difficult task of installing <a href="http://gstreamer.freedesktop.org/">GStreamer</a> on a windows machine. Besides, the latest "official" <a href="http://gstreamer.freedesktop.org/pkg/windows/releases/">installation packages </a>for windows haven't been updated for some time, while GStreamer code has been making continuous progress during the last months.</p>
<p>So, this situation was the motivation to create an alternative, simplified and up-to-date GStreamer installation package for windows. In fact, there is already a project with this very same goal, called <a href="http://people.collabora.co.uk/~oleavr/OABuild/">OABuild</a>, developed by Ole André Ravnas. OABuild contains a suite of MS Visual C++ projects that allows to compile GStreamer, among other useful open source libraries and tools, using the Microsoft compiler.</p>
<p>One problem with the current version of OABuild is that it includes a stripped-down version of <a href="http://ffmpeg.mplayerhq.hu/">FFmpeg</a>, in order to compile it with MSVC. FFmpeg is the underlying library in GStreamer that provides support for decoding tons of commonplace video formats. However, the FFmpeg included in OABuild only provides a few codecs and hence wasn't very useful to incorporate in a general GStreamer installer.</p>
<p>The aim of the following sections is to show the main tasks I had to accomplish in order to create this installer, starting with the compilation of a fully functional FFmpeg distribution under windows. This is not a step-by-step tutorial, only the steps or "tricks" I considered central for success are mentioned, while other details are assumed to be known.</p>
<p>Anyways, for those who are not interesting in these little nasty details, here you have a link where you can download the binary installer, as well as an installer of the development files, in case you need to compile applications that use GStreamer:</p>
<p><a href="http://sourceforge.net/project/showfiles.php?group_id=225389&#38;package_id=272648&#38;release_id=625609">20080911 release of GStreamerOABuild installer</a></p>
<p>Please note that this is an initial release intended mostly for testing and debugging. Please let me know of any issues you might find with it.</p>
<p><strong>Compiling FFmpeg under windows</strong></p>
<p>So, for the task of compiling the <a href="http://ffmpeg.mplayerhq.hu/download.html">latest source</a> of FFmpeg, the Microsoft compiler is not an option, since FFmpeg uses features of the <a href="http://en.wikipedia.org/wiki/C99">C99</a> specification of the C language which are not recognized by MSVC. What I did was to use <a href="http://www.mingw.org/">MinGW</a> and <a href="http://www.mingw.org/wiki/msys">MSYS</a> in order to compile FFmpeg with gcc, the GNU C compiler.</p>
<p>There were lots of useful information on how to compile and use FFmpeg on windows machines on <a href="http://arrozcru.no-ip.org/">this FFmpeg Windows help page</a>, specially in the wiki and forum sections. However, the wiki has been down for a couple of months. I was able to recover some data from the copies stored in the Google cache. The forum seems to be online again, though.</p>
<p>I set up a MinGW + MSYS development environment, but the latest stable release of MSYS (1.0.10) won't work to compile FFmepg because of an incompatibility between FFmpeg and the version of make included with 1.0.10. Version 1.0.11 solves this issue, and can be downloaded from <a href="http://sourceforge.net/project/showfiles.php?group_id=2435&#38;package_id=24963">here</a> as individual packages. I prepared an installer that contains all those files in a single package, you can grab it from <a href="http://users.design.ucla.edu/~acolubri/files/MSYS-1.0.11preview.exe">here</a>.</p>
<p>Once MinGW and MSYS are installed, you have to fix the msys.bat file that is inside the root MSYS folder. The steps to perform this fix according to the FFmpeg Windows help site (gotten from Google cache) are the following:</p>
<p><em>"Open <strong>C:\msys\msys.bat</strong> in a plain-text editor, such as <strong>notepad.exe</strong>.</em></p>
<p><em>If you plan on compiling your apps with MSVC++ (<strong>note: your apps, not FFmpeg</strong>), you will need <strong>.lib</strong> files to link against FFmpeg's libraries.<br />
Those <strong>.lib</strong> files can be generated by the <strong>lib</strong> command from the Microsoft's Toolchain.<br />
For that, you must have Microsoft Visual Studio, or Microsoft Visual C++.<br />
Add the following line to the beggining of <strong>msys.bat</strong>, replacing the path leading to <strong>vcvars32.bat</strong> to wherever that file is located in your computer:<br />
</em></p>
<div dir="ltr">
<pre class="codelisting"><em>call "C:\Program Files\Microsoft Visual Studio 8\VC\bin\vcvars32.bat"</em></pre>
</div>
<p><em> If you have Windows x64, you must add the following lines right after the <strong>:_WindowsNT</strong> label (line 36), or else the shell window will quickly open and close:<br />
</em></p>
<pre class="codelisting"><em>rem Hopefully a temporary workaround for getting MSYS shell to run on x64
rem (WoW64 cmd prompt sets PROCESSOR_ARCHITECTURE to x86)
if not "x%PROCESSOR_ARCHITECTURE%" == "xAMD64" goto _NotX64
set COMSPEC=%WINDIR%\SysWOW64\cmd.exe
%COMSPEC% /c %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
goto EOF
:_NotX64
"</em></pre>
<p>The next important "trick" is to update the gcc included in the latest stable MinGW (which should be 3.4.5) to 4.2 or higher, otherwise FFmpeg will give nasty errors about wrong compilation and not properly aligned stack variables... I have tried gcc 4.30-preview available on the sourceforge page of MinGW, but the resulting FFmpeg is also broken. Fortunately, a version of gcc 4.2.4 available at this <a href="http://www.tdragon.net/recentgcc/">website</a> worked fine. I was able to successfully compile FFmpeg (from the svn source snapshot taken on 2008-09-04) with the following configure parameters:</p>
<pre class="codelisting">--enable-shared --disable-static --enable-memalign-hack --enable-w32threads</pre>
<p>You can download a zip file containing the resulting dlls, lib files and headers from <a href="http://users.design.ucla.edu/~acolubri/files/ffmpeg-2008-09-04-gcc4.2.4-w32threads-SSE.zip">here</a>.</p>
<p><strong>Integration of MinGW-generated FFmpeg and OABuild</strong></p>
<p>Once I obtained the FFmpeg's dlls, lib and headers files, I had to remove the FFmpeg that comes included with OABuild by default and to create new MSVC projects for the MinGW-generated FFmpeg. The idea is to integrate these changes into the <a href="https://code.launchpad.net/oabuild">OABuild mainline</a> pretty soon.</p>
<p><strong>Fixes to OABuild</strong></p>
<p>I replaced the source code of gst-ffmpeg in OAbuild with the one from the latest stable release (0.10.5). This code needed some changes in order to compile from MSVC:</p>
<ul>
<li>Include &#60;libavcodec/avcodec.h&#62; and &#60;libavformat/avformat.h&#62; instead of &#60;ffmpeg/avcodec.h&#62; and &#60;ffmpeg/avformat.h&#62;</li>
<li>In gstffmpegenc.c do: replace in_plugin = first_avcodec; by in_plugin = av_codec_next(NULL); and in_plugin = in_plugin-&#62;next; by in_plugin = av_codec_next(in_plugin);</li>
<li>In gstffmpegdec.c, do: replace in_plugin = first_avcodec; by in_plugin = av_codec_next(NULL); and in_plugin = in_plugin-&#62;next; by in_plugin = av_codec_next(in_plugin);</li>
<li>In gstffmpegdemux.c, do: replace in_plugin = first_iformat; by in_plugin = av_iformat_next(NULL); and in_plugin = in_plugin-&#62;next; by in_plugin = av_iformat_next(in_plugin);</li>
<li>In gstffmpegmux.c, do: replace in_plugin = first_oformat; by in_plugin = av_oformat_next(NULL); and in_plugin = in_plugin-&#62;next;by in_plugin = av_oformat_next(in_plugin);</li>
</ul>
<p>Also, the qtdemux element wasn't included in OABuild. Without it is not possible to open quicktime mov files. Again, using the qtdemux code from the latest gst-plugins-good package, I created a project file inside OABuild. The following changes in code were needed in order to compile the pluign:</p>
<ul>
<li>In qtdemux_dump.h, change #include &#60;qtdemux.h&#62; with #include "qtdemux.h"</li>
<li>Then remove gstrtpxqtdepay.c y gstrtpxqtdepay.h from project.</li>
<li>Comment out the occurrence of gst_tag_freeform_string_to_utf8 in qtdemux.c and the following code: if (!gst_element_register (plugin, "rtpxqtdepay", GST_RANK_MARGINAL, GST_TYPE_RTP_XQT_DEPAY)) return FALSE; in quicktime.c</li>
</ul>
<p><strong>Creating binaries with the ReleaseWdkCrt option</strong></p>
<p>The binaries resulting from compiling with the Release option in OABuild won't work unless the machine where they are installed also has the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=9b2da534-3e03-4391-8a4d-074b9f2bc1bf&#38;displaylang=en">MSVC 2008 redistributable package</a> installed on it. It is a small nag, but ideally the GStreamer installer shouldn't need any aditional libraries in order to be it entirely self-contained. This is solved by using the ReleaseWdkCrt compiling option, which requires to use some CRT object files that come with the <a href="http://www.microsoft.com/whdc/devtools/wdk/default.mspx">Windows Driver Kit</a> (WDK). This is kind of a messy topic, and <a href="http://kobyk.wordpress.com/2007/07/20/dynamically-linking-with-msvcrtdll-using-visual-c-2005/">here</a> it is explained in detail the logic of this workaround. The WDK can be downloaded after creating a free account on <a href="http://connect.microsoft.com/">Microsoft Connect</a>. Then, only the <a href="http://users.design.ucla.edu/~acolubri/files/wdkcrt-filelist.txt">following files</a> from the WDK are needed to be copied inside &#60;OABuild root&#62;\build\builddeps\wdkcrt.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Compiling Wget for Windows Using MinGW and MSYS]]></title>
<link>http://telengard.wordpress.com/?p=93</link>
<pubDate>Mon, 08 Sep 2008 07:26:49 +0000</pubDate>
<dc:creator>telengard</dc:creator>
<guid>http://telengard.pl.wordpress.com/2008/09/08/compiling-wget-in-msys/</guid>
<description><![CDATA[Relevant Links
GNU Wget page
MinGW SourceForge page
UNIX / Linux Tutorial for Beginners
Down the Por]]></description>
<content:encoded><![CDATA[<h3>Relevant Links</h3>
<p><a href="http://www.gnu.org/software/wget/" target="_blank">GNU Wget page</a></p>
<p><a href="http://sourceforge.net/projects/mingw/" target="_blank">MinGW SourceForge page</a></p>
<p><a href="http://www.ee.surrey.ac.uk/Teaching/Unix/" target="_blank">UNIX / Linux Tutorial for Beginners</a></p>
<h3>Down the Port</h3>
<p>Download the <em>Current Release</em> of the Wget port, version 1.9.1 as of this post, from the link below:</p>
<p><a href="http://sourceforge.net/project/showfiles.php?group_id=2435&#38;package_id=233332" target="_blank">http://sourceforge.net/project/showfiles.php?group_id=2435&#38;package_id=233332</a></p>
<p><a href="http://www.divshare.com/download/5332450-35f"><img src="http://www.divshare.com/img/5332450-35f.png" border="0" /></a></p>
<p>Create the directory <em>C:\MSYS\1.0\src</em> and save the downloaded file to that path.</p>
<p><a href="http://www.divshare.com/download/5332260-89a"><img src="http://www.divshare.com/img/5332260-89a.png" border="0" /></a></p>
<p><strong>Note:</strong> If your MSYS is not installed on the standard path of <em>C:\MSYS</em> then you'll have to adjust the paths to match your installation.</p>
<h3>Preparation</h3>
<p>Start MSYS and then change to the <em>/usr/src</em> directory:</p>
<p><code>cd /usr/src</code></p>
<p>Extract the port, then change to the <em>wget-1.9.1/mingwport</em> directory:</p>
<p><code>tar xvjf wget-1.9.1-mingwPORT.tar.bz2<br />
cd wget-1.9.1/mingwport<br />
</code></p>
<p>Copy the <em>wget.exe</em> file to the <em>/tmp</em> directory:</p>
<p><code>cp -p wget.exe /tmp/</code></p>
<p><strong>Note:</strong> The port is a shell script that will download, configure, and make the Wget source automatically, after we answer a few prompts.</p>
<h3>Compiling Wget</h3>
<p>Execute the port script:</p>
<p><code>./mingwPORT.sh</code></p>
<p><a href="http://www.divshare.com/download/5332631-183"><img src="http://www.divshare.com/img/5332631-183.png" border="0" /></a></p>
<p>We will accept the default response to every prompt. Press the <em>enter</em> key in response to the prompt to accept the default.</p>
<p><a href="http://www.divshare.com/download/5333207-967"><img src="http://www.divshare.com/img/5333207-967.png" border="0" /></a></p>
<p> After pressing <em>enter</em> at the <em>CFLAGS</em> prompt the interactive stage ends and the script goes into fully automated operation.</p>
<p><strong>Note:</strong> You may need to <em>unblock wget</em> if the Windows Firewall asks, although I didn't.</p>
<p><a href="http://www.divshare.com/download/5333221-6b0"><img src="http://www.divshare.com/img/5333221-6b0.png" border="0" /></a></p>
<p><strong>Note:</strong> During the build process a great deal of text is output to the MSYS console, which you may need to refer back to if any errors occur.</p>
<h3>Last Steps</h3>
<p>Now install the Info pages for Wget:</p>
<p><code>install-info wget.info dir</code></p>
<p><a href="http://www.divshare.com/download/5333517-86c"><img src="http://www.divshare.com/img/5333517-86c.png" border="0" /></a></p>
<p>You're done.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Getting the Info Program to Work in MSYS]]></title>
<link>http://telengard.wordpress.com/?p=87</link>
<pubDate>Mon, 08 Sep 2008 06:07:10 +0000</pubDate>
<dc:creator>telengard</dc:creator>
<guid>http://telengard.pl.wordpress.com/2008/09/08/getting-the-info-program-to-work-in-msys/</guid>
<description><![CDATA[Relevant Links
HOWTO_Install_the_MinGW(GCC)_Compiler_Suite (Read keith&#8217;s comment on concatenat]]></description>
<content:encoded><![CDATA[<h3>Relevant Links</h3>
<p><a href="http://www.mingw.org/cms/wiki/HOWTO_Install_the_MinGW_%28GCC%29_Compiler_Suite" target="_blank">HOWTO_Install_the_MinGW(GCC)_Compiler_Suite</a> (Read keith's comment on <em>concatenation of info/dir files</em>.)</p>
<p><a href="http://www.gnu.org/software/hello/manual/texinfo/Invoking-install_002dinfo.html" target="_blank">Invoking install-info</a> (GNU Texinfo 4.12 manual page)</p>
<h3>Installing Info Files</h3>
<p>Start MSYS using the shortcut on the Windows desktop or All Programs menu. You'll have to exit MSYS at the end of this procedure.</p>
<p><code>cd /mingw/info<br />
for file in *.info; do install-info $file dir; done<br />
echo export INFOPATH=/mingw/info &#62;&#62; ~/.profile<br />
exit<br />
</code></p>
<p><a href="http://www.divshare.com/download/5328972-6ae"><img src="http://www.divshare.com/img/5328972-6ae.png" border="0" /></a></p>
<p><strong>Note:</strong> The info pages will be made available after you exit and restart MSYS.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Installing MinGW and MSYS on Windows XP]]></title>
<link>http://telengard.wordpress.com/?p=34</link>
<pubDate>Fri, 05 Sep 2008 21:16:55 +0000</pubDate>
<dc:creator>telengard</dc:creator>
<guid>http://telengard.pl.wordpress.com/2008/09/05/installing-mingw-and-msys-on-windows-xp/</guid>
<description><![CDATA[What I&#8217;m Up to
I want to install MinGW and MSYS on my computer so I can compile some open sour]]></description>
<content:encoded><![CDATA[<h3>What I'm Up to</h3>
<p>I want to install <a title="MinGW web site" href="http://www.mingw.org" target="_blank">MinGW and MSYS</a> on my computer so I can compile some open source programs. I have only a small amount of experience with Unix from school, and my time with <a title="Kubuntu web site" href="http://www.kubuntu.org" target="_blank">Kubuntu</a> to rely on. It should be a fun learning experience, but setting up a build environment with MinGW / MSYS is quite complicated.</p>
<p>I'm not taking anything away from the MinGW guys, because the work they do is very hard, and greatly beneficial to those who use open source software on Windows. Even so, I feel it necessary to blog about this, if only as a record of my attempts for my own future reference. Please don't assume anything I post about MinGW / MSYS is authoritative, or necessarily even correct. If you want to know the truth, try downloading MinGW / MSYS and working with it on your own.</p>
<h3>Relevant Links</h3>
<p><a title="Home page of MinGW and MSYS" href="http://www.mingw.org" target="_blank">http://www.mingw.org</a> (Home page of MinGW and MSYS)</p>
<p><a title="Project page of MinGW and MSYS on SourceForge.net" href="http://sourceforge.net/projects/mingw/">http://sourceforge.net/projects/mingw</a> (Project page of MinGW and MSYS on Sourceforge)</p>
<p><a title="http://www.vim.org" href="http://www.vim.org" target="_blank">http://www.vim.org</a> (Vim home online)</p>
<p><a title="Mastering the VI editor" href="http://www.eng.hawaii.edu/Tutor/vi.html" target="_blank">http://www.eng.hawaii.edu/Tutor/vi.html</a> ("Mastering the VI editor": University of Hawai`i, College of Engineering, Computer Facility)</p>
<p><a title="GCC, the GNU Compiler Collection" href="http://gcc.gnu.org" target="_blank">http://gcc.gnu.org</a> (Home page of the GNU Compiler Collection)</p>
<p><a title="UNIX / Linux Tutorial for Beginners" href="http://www.ee.surrey.ac.uk/Teaching/Unix/index.html">http://www.ee.surrey.ac.uk/Teaching/Unix/index.html</a> (UNIX / Linux Tutorial for Beginners)</p>
<h3>My Computer</h3>
<p>HP Pavilion dv8135nr, Windows XP Media Center Edition (Service Pack 3)</p>
<h3>About Package Versions</h3>
<p>I'm downloading the versions of each package that are available as I write this. In the future there will be newer versions of these packages, so don't expect your experience to be the same if the version numbers aren't the same. By all means please download the latest versions, and find your own way as you go.</p>
<h3>MinGW Installation</h3>
<p><strong>Note:</strong> It is advised to install MinGW first. The MSYS installer will normalize to your existing MinGW installation.</p>
<p>Download the <em>Automated MinGW Installer</em>, version 5.1.4 as of this post, from the link below:</p>
<p><a title="Automated MinGW Installer" href="https://sourceforge.net/project/showfiles.php?group_id=2435&#38;package_id=240780" target="_blank">https://sourceforge.net/project/showfiles.php?group_id=2435&#38;package_id=240780<br />
</a></p>
<p><a href="http://www.divshare.com/download/5324549-9be" target="_blank"><img src="http://www.divshare.com/img/midsize/5324549-9be.png" border="0" />click to expand image</a></p>
<p>Create the folder <em>C:\MinGW</em> and save the downloaded file there. Now you sould have the file <em>C:\MinGW\MinGW-5.1.4.exe</em>.</p>
<p><a href="http://www.divshare.com/download/5322126-510"><img src="http://www.divshare.com/img/5322126-510.png" border="0" alt="" /></a></p>
<p><strong>Important Note:</strong> Never install MinGW or MSYS on a path containing spaces!</p>
<p>Double click the MinGW-5.1.4.exe file to run the Automated MinGW Installer.</p>
<p><strong>Note:</strong> When the installer runs for the first time, it will perform a quick update check, and then create the <em>mingw.ini</em> file to record information about your installation.</p>
<p><a href="http://www.divshare.com/download/5325034-0e9"><img src="http://www.divshare.com/img/5325034-0e9.png" border="0" /></a></p>
<p>Follow along to answer the prompts as shown. Prompts are shown in italics, and actions you should take are in parentheses.</p>
<p><em>Welcome to MinGW . . .</em> (Click <em>Next</em>)</p>
<p><a href="http://www.divshare.com/download/5322127-b81"><img src="http://www.divshare.com/img/5322127-b81.png" border="0" alt="" /></a></p>
<p><em>Install or just download files?</em> (Choose<em> Downlaoad and install</em>, then click <em>Next</em>)</p>
<p><a href="http://www.divshare.com/download/5322128-f81"><img src="http://www.divshare.com/img/5322128-f81.png" border="0" alt="" /></a></p>
<p><em>License Agreement</em> (Click <em>I Agree</em>)</p>
<p><a href="http://www.divshare.com/download/5322129-806"><img src="http://www.divshare.com/img/5322129-806.png" border="0" alt="" /></a></p>
<p><em>Choose Package</em> (Choose <em>Current</em>, then click <em>Next</em>)</p>
<p><a href="http://www.divshare.com/download/5322134-984"><img src="http://www.divshare.com/img/5322134-984.PNG" border="0" alt="" /></a></p>
<p><em>Choose Components</em> (Checkmark <em>MinGW base tools</em> and <em>g++ compiler</em>, then click <em>Next</em>.)</p>
<p><a href="http://www.divshare.com/download/5322135-972"><img src="http://www.divshare.com/img/5322135-972.PNG" border="0" alt="" /></a></p>
<p><strong>Note:</strong> Do not checkmark <em>MinGW Make</em>!</p>
<p><em>Choose Install Location</em> (Note the default location of <em>C:\MinGW</em> and click <em>Next</em>)</p>
<p><a href="http://www.divshare.com/download/5322337-43d"><img src="http://www.divshare.com/img/5322337-43d.png" border="0" alt="" /></a></p>
<p><em>Choose Start Menu Folder</em> (Click <em>Install</em>)</p>
<p><a href="http://www.divshare.com/download/5322160-c48"><img src="http://www.divshare.com/img/5322160-c48.png" border="0" alt="" /></a></p>
<p><strong>Note:</strong> If the <em>Automated MinGW Installer</em> fails for any reason, check your Internet connection, and run the <em>Automated MinGW Installer</em> again.</p>
<p><em>Downloading . . .</em> (Wait and observe the process)</p>
<p><a href="http://www.divshare.com/download/5322189-435"><img src="http://www.divshare.com/img/5322189-435.png" border="0" alt="" /></a></p>
<p><em>Extracting . . .</em> (Wait and observe the process)</p>
<p><a href="http://www.divshare.com/download/5322179-6da"><img src="http://www.divshare.com/img/5322179-6da.png" border="0" alt="" /></a></p>
<p><em>Installation Complete</em> (Note the intallation log, then click <em>Next</em>.)</p>
<p><a href="http://www.divshare.com/download/5322190-efd"><img src="http://www.divshare.com/img/5322190-efd.png" border="0" alt="" /></a></p>
<p><em>MinGW has finished . . .</em> (Click <em>Finish</em>.)</p>
<p><a href="http://www.divshare.com/download/5325376-033"><img src="http://www.divshare.com/img/5325376-033.png" border="0" /></a></p>
<p><strong>Note:</strong> The Automated MinGW Installer has downloaded and extracted all required packages to the <em>C:\MinGW</em> folder.</p>
<p><a href="http://www.divshare.com/download/5325377-419" target="_blank"><img src="http://www.divshare.com/img/midsize/5325377-419.png" border="0" />click to expand image</a></p>
<p><strong>Note:</strong> The Automated MinGW Installer has also placed shortcuts in the Windows <em>All Programs</em> menu and <em>Add or Remove Programs</em> applet of the Control Panel.</p>
<p><a href="http://www.divshare.com/download/5325626-75b"><img src="http://www.divshare.com/img/5325626-75b.png" border="0" /></a></p>
<h3>MSYS Installation</h3>
<p>Download the <em>MSYS Base System</em> installer from the link below. Be sure to get the <em>Current Release</em>, version 1.0.10 as of this post.</p>
<p><a href="http://sourceforge.net/project/showfiles.php?group_id=2435&#38;package_id=24963&#38;release_id=89960" target="_blank">http://sourceforge.net/project/showfiles.php?group_id=2435&#38;package_id=24963&#38;release_id=89960</a></p>
<p><strong>Note:</strong> It may be necessary to scroll your browser window, or <em>drill down</em> the menu, until you find <em>Current Release: msys-1.0.10</em>.</p>
<p><a href="http://www.divshare.com/download/5325763-8ce" target="_blank"><img src="http://www.divshare.com/img/midsize/5325763-8ce.png" border="0" />click to expand image</a></p>
<p>Create the folder <em>C:\MSYS</em> and save the downloaded file there. Now you should have the file <em>C:\MSYS\MSYS-1.0.10.exe</em>.</p>
<p><a href="http://www.divshare.com/download/5322217-948"><img src="http://www.divshare.com/img/5322217-948.png" border="0" alt="" /></a></p>
<p><strong>Important Note:</strong> Never install MinGW or MSYS on a path containing spaces!</p>
<p>Double click the MSYS-1.0.10.exe file to run the installer, and answer the prompts as follows. Prompts are shown in italics, and actions you should take are in parentheses.</p>
<p><em>This will install "Minimal SYStem". Do you wish to continue?</em> (Click <em>Yes</em>)</p>
<p><a href="http://www.divshare.com/download/5322219-d06"><img src="http://www.divshare.com/img/5322219-d06.png" border="0" alt="" /></a></p>
<p><em>Welcome to the "Minimal SYStem" . . .</em> (Click <em>Next</em>)</p>
<p><a href="http://www.divshare.com/download/5322220-285"><img src="http://www.divshare.com/img/5322220-285.png" border="0" alt="" /></a></p>
<p><em>License Agreement</em> (Click <em>Yes</em>)</p>
<p><a href="http://www.divshare.com/download/5322221-951"><img src="http://www.divshare.com/img/5322221-951.png" border="0" alt="" /></a></p>
<p><em>Information</em> (Read the information, then click <em>Next</em>)</p>
<p><a href="http://www.divshare.com/download/5322222-6f9"><img src="http://www.divshare.com/img/5322222-6f9.png" border="0" alt="" /></a></p>
<p><em>Select Destination Directory</em> (Note the default location of <em>C:\msys\1.0</em>, then click <em>Next</em>)</p>
<p><a href="http://www.divshare.com/download/5322223-8b1"><img src="http://www.divshare.com/img/5322223-8b1.png" border="0" alt="" /></a></p>
<p><em>Select Components</em> (Accept the default of <em>i386 based CPUs</em>, and click <em>Next</em>)</p>
<p><a href="http://www.divshare.com/download/5322226-bb4"><img src="http://www.divshare.com/img/5322226-bb4.png" border="0" alt="" /></a></p>
<p><em>Select Start Menu Folder</em> (Click <em>Next</em>)</p>
<p><a href="http://www.divshare.com/download/5322227-2b0"><img src="http://www.divshare.com/img/5322227-2b0.png" border="0" alt="" /></a></p>
<p><em>Ready to Install</em> (Be sure the installation settings are correct, then click <em>Install</em>)</p>
<p><a href="http://www.divshare.com/download/5322228-270"><img src="http://www.divshare.com/img/5322228-270.png" border="0" alt="" /></a></p>
<p>The installer now runs a small batch program to complete the installation.</p>
<p><a href="http://www.divshare.com/download/5322229-6f6"><img src="http://www.divshare.com/img/5322229-6f6.png" border="0" alt="" /></a></p>
<h3>MSYS Post Install Process</h3>
<p>The batch program will open in a command line window, and prompt you to answer a few simple questions.  You must be especially careful in answering the prompts because the batch program may misunderstand a mistyped response.</p>
<p><a href="http://www.divshare.com/download/5325956-8e5" target="_blank"><img src="http://www.divshare.com/img/midsize/5325956-8e5.png" border="0" />click to expand image</a></p>
<p><strong>Note:</strong> Be sure to follow along carefully as the batch program will not give you a chance to correct any mistakes!</p>
<p>Read the texts in the command window fully, and answer the prompts as follows. Prompts are shown in <code>code style</code>, and actions you should take are in (parentheses).</p>
<p><code>C:\msys\1.0\postinstall&#62;..\bin\sh.exe pi.sh</p>
<p>This is a post install process that will try to normalize between<br />
your MinGW install if any as well as your previous MSYS installs<br />
if any.  I don't have any traps as aborts will not hurt anything.<br />
Do you wish to continue with the post install? [yn ]</code></p>
<p>(Type the lower case letter <em>y</em>, then type the <em>enter</em> key)</p>
<p><a href="http://www.divshare.com/download/5325957-e86" target="_blank"><img src="http://www.divshare.com/img/midsize/5325957-e86.png" border="0" />click to expand image</a></p>
<p><strong>Note:</strong> By <em>type</em> I mean you should press and quickly release the key.</p>
<p><code>Do you have MinGW installed? [yn ]</code></p>
<p>(Type the lower case letter <strong>y</strong>, then the <strong>enter</strong> key)</p>
<p><a href="http://www.divshare.com/download/5325958-98c"><img src="http://www.divshare.com/img/5325958-98c.png" border="0" /></a></p>
<p><strong>Note:</strong> Pay special attention to the path delimiters used in the next prompt because we are expected to use the <em>forward slash</em>, usually found on the same key as <em>question mark</em>.</p>
<p><code>Please answer the following in the form of c:/foo/bar.<br />
Where is your MinGW installation?</code></p>
<p>(Type the full path of the MinGW folder in the format shown by the prompt.)</p>
<p><a href="http://www.divshare.com/download/5325959-8a6"><img src="http://www.divshare.com/img/5325959-8a6.png" border="0" /></a></p>
<p><strong>Note:</strong> Recall that we chose the location <em>C:\MinGW</em> during the MinGW installation process.</p>
<p><strong>Note:</strong> If you typed the path incorrectly, perhaps by using anything other than the <em>forward slash</em> as a path delimiter, then you'll be required to manually edit the /etc/fstab file after completing MSYS installation.</p>
<p>There will be no further interaction with the batch program after you press the <em>enter</em> key. If you typed all responses correctly up to this point, then the command prompt window will look like the image below.</p>
<p><a href="http://www.divshare.com/download/5326397-8a5" target="_blank"><img src="http://www.divshare.com/img/midsize/5326397-8a5.png" border="0" />click to expand image</a></p>
<p>(Type the <em>enter</em> key.)</p>
<p><code>Creating /etc/fstab with mingw mount bindings.<br />
        Normalizing your MSYS environment.</p>
<p>You have script /bin/awk<br />
You have script /bin/cmd<br />
You have script /bin/echo</p>
<p>You have script /bin/egrep<br />
You have script /bin/ex<br />
You have script /bin/fgrep<br />
You have script /bin/printf<br />
You have script /bin/pwd<br />
You have script /bin/rvi<br />
You have script /bin/rview<br />
You have script /bin/rvim<br />
You have script /bin/vi<br />
You have script /bin/view</p>
<p>Oh joy, you do not have c:/MinGW/bin/make.exe. Keep it that way.</p>
<p>C:\msys\1.0\postinstall&#62;pause<br />
Press any key to continue . . .</code></p>
<p>(Type the <em>enter</em> key one time to proceed)</p>
<p><a href="http://www.divshare.com/download/5322238-05e" target="_blank"><img src="http://www.divshare.com/img/midsize/5322238-05e.png" border="0" />click to expand image</a></p>
<p><strong>Note:</strong> Observe that we are advised not to install <em>MinGW Make</em>. </p>
<p>Now we go back to the <em>Setup - "Minimal SYStem"</em> installer window. The process is complete.</p>
<p><em>Setup has finished installing "Minimal SYStem" . . .</em> (Click <em>Finish</em>)</p>
<p><a href="http://www.divshare.com/download/5322239-d7e"><img src="http://www.divshare.com/img/5322239-d7e.png" border="0" alt="" /></a></p>
<p><strong>Note:</strong> If you left the two boxes check marked, as you should have, you will see two document windows with important texts which you should now read.</p>
<p><a href="http://www.divshare.com/download/5322240-f72" target="_blank"><img src="http://www.divshare.com/img/midsize/5322240-f72.png" border="0" alt="" />click to expand image</a></p>
<p><strong>Note:</strong> You can read the MSYS documentation again later. They are located at <em>C:\MSYS\1.0\doc</em>, if you've followed along.</p>
<p><a><img src="http://www.divshare.com/img/midsize/5322241-ea9.png" border="0" alt="" />click to expand image</a></p>
<p><strong>Note:</strong> MSYS is installed to the path <em>C:\MSYS\1.0</em>, which will become the root of the MSYS virtual file system.</p>
<p><a href="http://www.divshare.com/download/5326754-464" target="_blank"><img src="http://www.divshare.com/img/midsize/5326754-464.png" border="0" />click to expand image</a></p>
<p><strong>Note:</strong> Shortcuts for MSYS have  been added to the Windows desktop, <em>All Programs</em> menu, and <em>Add or Remove Programs</em> applet of the Control Panel.</p>
<p><a href="http://www.divshare.com/download/5326940-534"><img src="http://www.divshare.com/img/5326940-534.png" border="0" /></a></p>
<h3>Write a Test Program</h3>
<p>We'll create a simple C program and compile it with GCC to test our installation.</p>
<p>Start by double clicking the MSYS icon on your desktop, or clicking the MSYS icon in your <em>Start</em> menu's <em>All Programs</em> sub menu. Alternatively, you may also start MSYS by executing the <em>C:\MSYS\1.0\msys.bat</em> batch program.</p>
<p><a href="http://www.divshare.com/download/5322242-642"><img src="http://www.divshare.com/img/5322242-642.png" border="0" alt="" /></a></p>
<p>MSYS opens an rxvt terminal with a Unix command prompt. If you are not familiar with Unix, then you'll need a good tutorial on the subject. I'm not teaching Unix here, but I encourage you to <a title="UNIX / Linux Tutorial for Beginners" href="http://www.ee.surrey.ac.uk/Teaching/Unix/index.html" target="_blank">learn Unix</a> if you have the patience.</p>
<p><a href="http://www.divshare.com/download/5322254-66c" target="_blank"><img src="http://www.divshare.com/img/midsize/5322254-66c.png" border="0" />click to expand image</a></p>
<p>I'll be using the <a title="Vim home page" href="http://www.vim.org/" target="_blank">Vim text editor</a> which is included with MSYS. Be advised that the MSYS package has omitted the Vim documentation.  If you don't know Vim, then I <strong>strongly</strong> advise you to <a title="Mastering the VI editor" href="http://www.eng.hawaii.edu/Tutor/vi.html">read a good tutorial</a> first. Teaching you to use Vim is far, <em>far</em> beyond the scope of this post.</p>
<p><strong>IMPORTANT NOTE: </strong>Many people have floundered hopelessly on their first encounter with Vim, myself included. Some people love Vim for it's power and efficiency, and justifiably so, but I am not one of them. I'm hoping to successfully compile <a title="GNU Emacs" href="http://www.gnu.org/software/emacs" target="_blank">Emacs</a> later, but feel free to use Vim all you like if it suits you better.</p>
<p>In the MSYS terminal, create a directory named <em>hello</em> in your home directory and change to the new directory.<br />
<code>mkdir ~/hello<br />
cd ~/hello</code><br />
Now enter the command <em>vim hello.c</em> to begin editing the C source code file.<br />
<code>vim hello.c</code><br />
<a href="http://www.divshare.com/download/5322255-94a"><img src="http://www.divshare.com/img/5322255-94a.png" border="0" alt="" /></a></p>
<p>Type in the code, shown below in preformatted  style. Write the file to disk, and quit  from Vim.<br />
<code>#include &#60;stdio.h&#62;</p>
<p>int main(void) {<br />
  printf("Hello, World!");<br />
  return 0;<br />
}</code><br />
<a href="http://www.divshare.com/download/5322256-eb3"><img src="http://www.divshare.com/img/5322256-eb3.png" border="0" alt="" /></a></p>
<p><strong>Note:</strong> If you have any difficulty editing the source code in Vim, then please <a title="Mastering the Vi editor" href="http://www.eng.hawaii.edu/Tutor/vi.html" target="_blank">go to the tutorial</a> and read it. Don't say you weren't warned!</p>
<p><a href="http://www.divshare.com/download/5322257-06c"><img src="http://www.divshare.com/img/5322257-06c.png" border="0" alt="" /></a></p>
<p>Now compile the code with GCC:<br />
<code>gcc -ohello.exe hello.c</code><br />
Test the compiled code by running the generated executable:<br />
<code>./hello.exe</code><br />
<a href="http://www.divshare.com/download/5322258-b9e"><img src="http://www.divshare.com/img/5322258-b9e.png" border="0" alt="" /></a></p>
<p>If the hello message is printed and no errors are reported, then you're good to go with MinGW and MSYS!</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Компиляция программ для Windows в Eclipse с помощью MinGW]]></title>
<link>http://nidvoray.wordpress.com/?p=20</link>
<pubDate>Wed, 03 Sep 2008 21:02:50 +0000</pubDate>
<dc:creator>nidvoray</dc:creator>
<guid>http://nidvoray.pl.wordpress.com/2008/09/04/eclipse-mingw-win/</guid>
<description><![CDATA[&#8220;При компиляции программы с помощью MinGW добавьте фл]]></description>
<content:encoded><![CDATA[<p>"При компиляции программы с помощью MinGW добавьте флаг -mwindows, чтобы предотвратить ошибки компоновщика ... undefined reference to 'TextOutA@20' и ... undefined reference to 'GetStockObject@4."</p>
<p>(<a href="http://www.adp-gmbh.ch/win/programming/simple_win.html" target="_blank">A simple windows program in c</a>)</p>
<p>Этот флаг добавляется в Project -&#62; Properties, C/C++ Build -&#62;Settings-&#62;Tool Settings-&#62;MinGW C++ Linker в поле Command: после g++ (получается "g++ -mwindows") .</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Tuto: Installer Boost sous Windows avec MinGW]]></title>
<link>http://devtricks.wordpress.com/?p=33</link>
<pubDate>Thu, 21 Aug 2008 11:58:41 +0000</pubDate>
<dc:creator>superbob56</dc:creator>
<guid>http://devtricks.pl.wordpress.com/2008/08/21/tuto-installer-boost-sous-windows-avec-mingw/</guid>
<description><![CDATA[Bonjour,
Après un peu d&#8217;inactivité sur ce blog, voici un nouveau tutoriel.
Il décrit les é]]></description>
<content:encoded><![CDATA[<p>Bonjour,</p>
<p>Après un peu d'inactivité sur ce blog, voici un nouveau tutoriel.<br />
Il décrit les étapes pour installer les célèbres (ou pas) librairies Boost sur Windows avec MinGW.</p>
<p>Si vous ne connaissez pas Boost, c'est un ensemble de librairies pour le C++ qui permettent de faire tout un tas de choses et qui sont très bien réputées. Pour plus d'info, je vous invite à aller voir leur site officiel : <a title="Boost" href="http://www.boost.org/" target="_blank">http://www.boost.org/</a></p>
<p>Ce tuto est accessible via le lien suivant : <a href="http://devtricks.wordpress.com/installer-boost-sous-windows-avec-mingw/" target="_blank">http://devtricks.wordpress.com/installer-boost-sous-windows-avec-mingw/</a></p>
<p>Amusez-vous bien !</p>
<p>Bob</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[DirectX9 : Eclipse + CDT + MinGW]]></title>
<link>http://zenedith.wordpress.com/?p=113</link>
<pubDate>Sun, 03 Aug 2008 14:45:59 +0000</pubDate>
<dc:creator>zenedith</dc:creator>
<guid>http://zenedith.pl.wordpress.com/2008/08/03/directx9-eclipse-mingw/</guid>
<description><![CDATA[W ostatnim wpisie było o SDL i poniekąd o OpenGL (OGL), więc dla równowagi coś dla &#8220;panuj]]></description>
<content:encoded><![CDATA[<p>W ostatnim wpisie było o SDL i poniekąd o OpenGL (OGL), więc dla równowagi coś dla "panującego standardu", oczywiście z wykorzystaniem Eclipse, CDT i MinGW. Tak naprawdę  nie wysiliłem się za bardzo, ponieważ wziąłem przykładowy kod aplikacji DX z template'a dołączonego do <a href="http://www.codeblocks.org/" target="_blank">Code::Blocks</a>.<!--more--><br />
Zaczynamy standardowo od stworzenie projektu "pustej" aplikacji c++ w Eclipse. Zakładam, że Eclipse jest skonfigurowane do pracy z CDT i toolchain'em MinGW (jeśli nie to odsyłam do <a href="http://zenedith.wordpress.com/2008/07/02/cpp-ide-eclipse-mingw/">poprzednich</a> wpisów).<br />
Tym razem wprowadzanych ustawień będzie bardzo mało, ponieważ dodamy tylko jedną bibliotekę statyczną <strong>d3d9</strong> - wynika to z faktu, że prezentowany przykład jest bardzo prosty.</p>
<p style="text-align:center;"><a href="http://zenedith.wordpress.com/files/2008/08/dx_lib.jpg"><img class="size-thumbnail wp-image-114 aligncenter" src="http://zenedith.wordpress.com/files/2008/08/dx_lib.jpg?w=125" alt="" width="125" height="96" /></a></p>
<p>Czas najwyższy na podanie kodu aplikacji:</p>
<pre class="geshi"><span style="color:#339900;">#include &#60;d3d9.h&#62;</span>

LPDIRECT3D9       pD3D9       = <span style="color:#0000cc;">NULL</span>;
LPDIRECT3DDEVICE9 pD3D9Device = <span style="color:#0000cc;">NULL</span>;

HRESULT InitialiseD3D<span style="color:#000000;">(</span>HWND hWnd<span style="color:#000000;">)</span>
<span style="color:#000000;">{</span>
  <span style="color:#ff0000;">// First of all, create the main D3D object. If it is created successfully</span>
  <span style="color:#ff0000;">// we should get a pointer to an IDirect3D8 interface.</span>
 pD3D9 = Direct3DCreate9<span style="color:#000000;">(</span> D3D_SDK_VERSION <span style="color:#000000;">)</span>;
<span style="color:#0000cc;">if</span> <span style="color:#000000;">(</span> !pD3D9 <span style="color:#000000;">)</span>
<span style="color:#000000;">{</span>
MessageBox<span style="color:#000000;">(</span> <span style="color:#0000dd;">0</span>, <span style="color:#666666;">"Direct3DCreate9() - Failed"</span>, <span style="color:#0000dd;">0</span>, <span style="color:#0000dd;">0</span> <span style="color:#000000;">)</span>;
<span style="color:#0000cc;">return</span> <span style="color:#0000dd;">0</span>;

<span style="color:#000000;">}</span>

  <span style="color:#ff0000;">//Get the current display mode</span>
  D3DDISPLAYMODE d3ddm;
  <span style="color:#0000cc;">if</span><span style="color:#000000;">(</span>FAILED<span style="color:#000000;">(</span>pD3D9-&#62;GetAdapterDisplayMode<span style="color:#000000;">(</span>D3DADAPTER_DEFAULT, &#38;d3ddm<span style="color:#000000;">)</span><span style="color:#000000;">)</span><span style="color:#000000;">)</span>
  <span style="color:#000000;">{</span>
    <span style="color:#0000cc;">return</span> E_FAIL;
  <span style="color:#000000;">}</span>

D3DPRESENT_PARAMETERS D3Dpp;
ZeroMemory<span style="color:#000000;">(</span> &#38;D3Dpp, <span style="color:#0000dd;">sizeof</span><span style="color:#000000;">(</span>D3Dpp<span style="color:#000000;">)</span> <span style="color:#000000;">)</span>;
D3Dpp.<span style="color:#bb00cc;">Windowed</span> = <span style="color:#0000cc;">TRUE</span>;
D3Dpp.<span style="color:#bb00cc;">SwapEffect</span> = D3DSWAPEFFECT_DISCARD;

<span style="color:#0000cc;">if</span> <span style="color:#000000;">(</span> FAILED<span style="color:#000000;">(</span> pD3D9-&#62;CreateDevice<span style="color:#000000;">(</span> D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &#38;D3Dpp, &#38;pD3D9Device <span style="color:#000000;">)</span> <span style="color:#000000;">)</span> <span style="color:#000000;">)</span>
<span style="color:#000000;">{</span>
MessageBox<span style="color:#000000;">(</span> <span style="color:#0000dd;">0</span>, <span style="color:#666666;">"CreateDevice() - Failed"</span>, <span style="color:#0000dd;">0</span>, <span style="color:#0000dd;">0</span> <span style="color:#000000;">)</span>;
  <span style="color:#0000cc;">if</span><span style="color:#000000;">(</span>pD3D9 != <span style="color:#0000cc;">NULL</span><span style="color:#000000;">)</span>
  <span style="color:#000000;">{</span>
    pD3D9-&#62;Release<span style="color:#000000;">(</span><span style="color:#000000;">)</span>;
    pD3D9 = <span style="color:#0000cc;">NULL</span>;
  <span style="color:#000000;">}</span>
<span style="color:#0000cc;">return</span> <span style="color:#0000dd;">0</span>;

<span style="color:#000000;">}</span>

  <span style="color:#0000cc;">return</span> S_OK;
<span style="color:#000000;">}</span>

<span style="color:#0000cc;">void</span> Render<span style="color:#000000;">(</span><span style="color:#000000;">)</span>
<span style="color:#000000;">{</span>
  <span style="color:#0000cc;">if</span><span style="color:#000000;">(</span>pD3D9Device == <span style="color:#0000cc;">NULL</span><span style="color:#000000;">)</span>
  <span style="color:#000000;">{</span>
    <span style="color:#0000cc;">return</span>;
  <span style="color:#000000;">}</span>

  <span style="color:#ff0000;">// Clear the backbuffer to blue</span>
  pD3D9Device-&#62;Clear<span style="color:#000000;">(</span><span style="color:#0000dd;">0</span>, <span style="color:#0000cc;">NULL</span>, D3DCLEAR_TARGET,
                      D3DCOLOR_XRGB<span style="color:#000000;">(</span><span style="color:#0000dd;">0</span>, <span style="color:#0000dd;">0</span>, <span style="color:#0000dd;">255</span><span style="color:#000000;">)</span>, <span style="color:#0000dd;">1</span>.0f, <span style="color:#0000dd;">0</span><span style="color:#000000;">)</span>;

  <span style="color:#ff0000;">// Begin the scene</span>
  pD3D9Device-&#62;BeginScene<span style="color:#000000;">(</span><span style="color:#000000;">)</span>;

  <span style="color:#ff0000;">// Fill in here the rendering of other objects</span>

  <span style="color:#ff0000;">// End the scene</span>
  pD3D9Device-&#62;EndScene<span style="color:#000000;">(</span><span style="color:#000000;">)</span>;

  <span style="color:#ff0000;">// Fill back and front buffers so that back buffer will be visible on screen</span>
  pD3D9Device-&#62;Present<span style="color:#000000;">(</span><span style="color:#0000cc;">NULL</span>, <span style="color:#0000cc;">NULL</span>, <span style="color:#0000cc;">NULL</span>, <span style="color:#0000cc;">NULL</span><span style="color:#000000;">)</span>;
<span style="color:#000000;">}</span>

<span style="color:#0000cc;">void</span> CleanUp<span style="color:#000000;">(</span><span style="color:#000000;">)</span>
<span style="color:#000000;">{</span>
  <span style="color:#0000cc;">if</span><span style="color:#000000;">(</span>pD3D9Device != <span style="color:#0000cc;">NULL</span><span style="color:#000000;">)</span>
  <span style="color:#000000;">{</span>
    pD3D9Device-&#62;Release<span style="color:#000000;">(</span><span style="color:#000000;">)</span>;
    pD3D9Device = <span style="color:#0000cc;">NULL</span>;
  <span style="color:#000000;">}</span>

  <span style="color:#0000cc;">if</span><span style="color:#000000;">(</span>pD3D9 != <span style="color:#0000cc;">NULL</span><span style="color:#000000;">)</span>
  <span style="color:#000000;">{</span>
    pD3D9-&#62;Release<span style="color:#000000;">(</span><span style="color:#000000;">)</span>;
    pD3D9 = <span style="color:#0000cc;">NULL</span>;
  <span style="color:#000000;">}</span>
<span style="color:#000000;">}</span>

<span style="color:#0000cc;">void</span> MainLoop<span style="color:#000000;">(</span><span style="color:#000000;">)</span>
<span style="color:#000000;">{</span>
  <span style="color:#ff0000;">// Enter the main loop</span>
  MSG  msg;
  <span style="color:#0000cc;">BOOL</span> bMessage;

  PeekMessage<span style="color:#000000;">(</span>&#38;msg, <span style="color:#0000cc;">NULL</span>, 0U, 0U, PM_NOREMOVE<span style="color:#000000;">)</span>;

  <span style="color:#0000cc;">while</span><span style="color:#000000;">(</span>msg.<span style="color:#bb00cc;">message</span> != WM_QUIT<span style="color:#000000;">)</span>
  <span style="color:#000000;">{</span>
    bMessage = PeekMessage<span style="color:#000000;">(</span>&#38;msg, <span style="color:#0000cc;">NULL</span>, 0U, 0U, PM_REMOVE<span style="color:#000000;">)</span>;

    <span style="color:#0000cc;">if</span><span style="color:#000000;">(</span>bMessage<span style="color:#000000;">)</span>
    <span style="color:#000000;">{</span>
      <span style="color:#ff0000;">// Process message</span>
      TranslateMessage<span style="color:#000000;">(</span>&#38;msg<span style="color:#000000;">)</span>;
      DispatchMessage<span style="color:#000000;">(</span>&#38;msg<span style="color:#000000;">)</span>;
    <span style="color:#000000;">}</span>
    <span style="color:#0000cc;">else</span>
    <span style="color:#000000;">{</span>
      Render<span style="color:#000000;">(</span><span style="color:#000000;">)</span>; <span style="color:#ff0000;">// No message to process -&#62; render the scene</span>
    <span style="color:#000000;">}</span>
  <span style="color:#000000;">}</span><span style="color:#ff0000;">// while</span>
<span style="color:#000000;">}</span>

<span style="color:#ff0000;">// The windows message handler</span>
LRESULT WINAPI WinProc<span style="color:#000000;">(</span>HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam<span style="color:#000000;">)</span>
<span style="color:#000000;">{</span>
  <span style="color:#0000cc;">switch</span><span style="color:#000000;">(</span>msg<span style="color:#000000;">)</span>
  <span style="color:#000000;">{</span>
    <span style="color:#0000cc;">case</span> WM_DESTROY:
      PostQuitMessage<span style="color:#000000;">(</span><span style="color:#0000dd;">0</span><span style="color:#000000;">)</span>;
      <span style="color:#0000cc;">return</span> <span style="color:#0000dd;">0</span>;
      <span style="color:#0000cc;">break</span>;

    <span style="color:#0000cc;">case</span> WM_KEYUP:
      <span style="color:#0000cc;">switch</span> <span style="color:#000000;">(</span>wParam<span style="color:#000000;">)</span>
      <span style="color:#000000;">{</span>
        <span style="color:#0000cc;">case</span> VK_ESCAPE:
          <span style="color:#ff0000;">// Escape key pressed -&#62; exit</span>
          DestroyWindow<span style="color:#000000;">(</span>hWnd<span style="color:#000000;">)</span>;
          <span style="color:#0000cc;">return</span> <span style="color:#0000dd;">0</span>;
          <span style="color:#0000cc;">break</span>;
      <span style="color:#000000;">}</span>
      <span style="color:#0000cc;">break</span>;
  <span style="color:#000000;">}</span><span style="color:#ff0000;">// switch</span>

  <span style="color:#0000cc;">return</span> DefWindowProc<span style="color:#000000;">(</span>hWnd, msg, wParam, lParam<span style="color:#000000;">)</span>;
<span style="color:#000000;">}</span>

<span style="color:#ff0000;">// Application main entry point</span>
<span style="color:#0000cc;">INT</span> WINAPI WinMain<span style="color:#000000;">(</span>HINSTANCE hInst, HINSTANCE, LPSTR, <span style="color:#0000cc;">INT</span><span style="color:#000000;">)</span>
<span style="color:#000000;">{</span>
  <span style="color:#ff0000;">//Register the window class</span>
  WNDCLASSEX wc = <span style="color:#000000;">{</span> <span style="color:#0000dd;">sizeof</span><span style="color:#000000;">(</span>WNDCLASSEX<span style="color:#000000;">)</span>, CS_CLASSDC, WinProc, 0L, 0L,
                    GetModuleHandle<span style="color:#000000;">(</span><span style="color:#0000cc;">NULL</span><span style="color:#000000;">)</span>, <span style="color:#0000cc;">NULL</span>, <span style="color:#0000cc;">NULL</span>, <span style="color:#0000cc;">NULL</span>, <span style="color:#0000cc;">NULL</span>,
                    <span style="color:#666666;">"DirectX Project"</span>, <span style="color:#0000cc;">NULL</span> <span style="color:#000000;">}</span>;
  RegisterClassEx<span style="color:#000000;">(</span>&#38;wc<span style="color:#000000;">)</span>;

  <span style="color:#ff0000;">// Create the application's main window</span>
  HWND hWnd = CreateWindow<span style="color:#000000;">(</span><span style="color:#666666;">"DirectX Project"</span>, <span style="color:#666666;">"DirectX9 APP : Eclipse + CDT + MinGW"</span>,
                           WS_OVERLAPPEDWINDOW, <span style="color:#0000dd;">50</span>, <span style="color:#0000dd;">50</span>, <span style="color:#0000dd;">500</span>, <span style="color:#0000dd;">500</span>,
                           GetDesktopWindow<span style="color:#000000;">(</span><span style="color:#000000;">)</span>, <span style="color:#0000cc;">NULL</span>, wc.<span style="color:#bb00cc;">hInstance</span>, <span style="color:#0000cc;">NULL</span><span style="color:#000000;">)</span>;

  <span style="color:#ff0000;">// Initialize Direct3D</span>
  <span style="color:#0000cc;">if</span><span style="color:#000000;">(</span>SUCCEEDED<span style="color:#000000;">(</span>InitialiseD3D<span style="color:#000000;">(</span>hWnd<span style="color:#000000;">)</span><span style="color:#000000;">)</span><span style="color:#000000;">)</span>
  <span style="color:#000000;">{</span>
    <span style="color:#ff0000;">// Show window</span>
    ShowWindow<span style="color:#000000;">(</span>hWnd, SW_SHOWDEFAULT<span style="color:#000000;">)</span>;
    UpdateWindow<span style="color:#000000;">(</span>hWnd<span style="color:#000000;">)</span>;

    <span style="color:#ff0000;">//Start game running: Enter the game loop</span>
    MainLoop<span style="color:#000000;">(</span><span style="color:#000000;">)</span>;
  <span style="color:#000000;">}</span>

  CleanUp<span style="color:#000000;">(</span><span style="color:#000000;">)</span>;

  UnregisterClass<span style="color:#000000;">(</span><span style="color:#666666;">"DirectX Project"</span>, wc.<span style="color:#bb00cc;">hInstance</span><span style="color:#000000;">)</span>;

  <span style="color:#0000cc;">return</span> <span style="color:#0000dd;">0</span>;
<span style="color:#000000;">}</span></pre>
<p>Efektem będzie okienko wypełnione kolorem niebieskim. Aż się prosi aby uzupełnić metodę Render() o dowolne efekty..</p>
<p style="text-align:center;"><a href="http://zenedith.wordpress.com/files/2008/08/dx_app.jpg"><img class="alignnone size-thumbnail wp-image-116" src="http://zenedith.wordpress.com/files/2008/08/dx_app.jpg?w=96" alt="" width="96" height="96" /></a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[SDL : Eclipse + CDT + MinGW]]></title>
<link>http://zenedith.wordpress.com/?p=96</link>
<pubDate>Sat, 02 Aug 2008 23:28:01 +0000</pubDate>
<dc:creator>zenedith</dc:creator>
<guid>http://zenedith.pl.wordpress.com/2008/08/03/sdl-eclipse-cdt-mingw/</guid>
<description><![CDATA[Ponieważ wiele razy wspominałem, ile dobrego zawiera w sobie na starcie MinGW Distro - nuwen.net, ]]></description>
<content:encoded><![CDATA[<p>Ponieważ wiele razy wspominałem, ile dobrego zawiera w sobie na starcie <a href="http://nuwen.net/mingw.html">MinGW Distro - nuwen.net</a>, dziś stworzymy okienko Windows'a za pomocą SDL. W skrócie można rzecz, że jest to bardzo prosty interfejs do OpenGL lecz jego jedyną wadą jest ta, że działa on software'owo, nie wykorzystując w pełni karty graficznej.. Oczywiście możemy brać z SDL to co najlepsze a resztę robić w "<em>pure</em>" OGL:)<!--more--></p>
<p>Ok, na start należy mieć:</p>
<ol>
<li>Wspomnianą dystrybucję MinGW,</li>
<li>Eclipse wraz z CDT skonfigurowane z toolchain'em  MinGW.</li>
</ol>
<p>Najprościej będzie więc wykonać kroki z <a href="http://zenedith.wordpress.com/2008/07/02/cpp-ide-eclipse-mingw/">tego </a>wpisu..</p>
<p>Stwórzmy teraz nowy projekt cpp i udajmy się do jego właściwości. Istotne dla nas będzie ustawienie katalogu include (<strong>Tool settings/GCC C++ Compiler/Directories</strong>) na podkatalog <strong>include </strong>w miejscu, gdzie rozpakujemy wspomniane wyżej distro MinGW (np. <em>D:\PRO\MinGW\include</em>) oraz katalogu i plików bibliotek statycznych lib (analogicznie pokatalog lib dystrybucji, czyli np. <em>D:\PRO\MinGW\lib</em>). W tym miejscu (<strong>Tool settings/MinGW C++ Linker/Libraries</strong>) oprócz ścieżki do podkatalogu <strong>lib</strong>, musimy wprowadzić także nazwy bibliotek statycznych, które będą użyte przez aplikację SDL - dwie najważniejsze to <strong>SDL_main oraz sdl, przy zachowaniu ich kolejności!</strong></p>
<p style="text-align:center;"><a href="http://zenedith.wordpress.com/files/2008/08/lib_sdl.jpg"><img class="alignnone size-thumbnail wp-image-97" src="http://zenedith.wordpress.com/files/2008/08/lib_sdl.jpg?w=126" alt="" width="126" height="96" /></a></p>
<p>Teraz dodajmy trochę kodu:</p>
<pre class="geshi"><span style="color:#339900;">#include &#60;SDL/SDL.h&#62;</span>
<span style="color:#339900;">#undef main</span>

<span style="color:#0000cc;">int</span> main<span style="color:#000000;">(</span><span style="color:#000000;">)</span><span style="color:#000000;">{</span>
	SDL_Surface * cSurface;
	<span style="color:#0000cc;">if</span><span style="color:#000000;">(</span>SDL_Init<span style="color:#000000;">(</span>SDL_INIT_VIDEO<span style="color:#000000;">)</span> &#60; <span style="color:#0000dd;">0</span><span style="color:#000000;">)</span> <span style="color:#000000;">{</span>
		<span style="color:#0000dd;">printf</span><span style="color:#000000;">(</span><span style="color:#666666;">"SDL_Init error..<span style="font-weight:bold;color:#666666;">\n</span>"</span><span style="color:#000000;">)</span>;
		<span style="color:#0000cc;">return</span> <span style="color:#0000dd;">1</span>;
	<span style="color:#000000;">}</span>

	<span style="color:#0000dd;">atexit</span><span style="color:#000000;">(</span>SDL_Quit<span style="color:#000000;">)</span>;

	cSurface = SDL_SetVideoMode<span style="color:#000000;">(</span><span style="color:#0000dd;">1024</span>, <span style="color:#0000dd;">768</span>, <span style="color:#0000dd;">32</span>, SDL_ANYFORMAT<span style="color:#000000;">)</span>;

	<span style="color:#0000cc;">if</span><span style="color:#000000;">(</span>!cSurface<span style="color:#000000;">)</span> <span style="color:#000000;">{</span>
		<span style="color:#0000dd;">printf</span><span style="color:#000000;">(</span><span style="color:#666666;">"SDL_SetVideoMode error..<span style="font-weight:bold;color:#666666;">\n</span>"</span><span style="color:#000000;">)</span>;
		<span style="color:#0000cc;">return</span> <span style="color:#0000dd;">1</span>;
	<span style="color:#000000;">}</span>
	SDL_Delay<span style="color:#000000;">(</span><span style="color:#0000dd;">5000</span><span style="color:#000000;">)</span>;<span style="color:#ff0000;">//czekaj 5 sekund i wyjdz..</span>
	<span style="color:#0000cc;">return</span> <span style="color:#0000dd;">0</span>;
<span style="color:#000000;">}
</span></pre>
<p>Uwagę należy zwrócić jedynie na jedną rzecz:<br />
<span style="color:#339900;">#undef main</span><br />
która dodana jest <strong>pomiędzy </strong>import nagłówka <strong>SDL.h</strong> a metodą <strong>main()</strong>. Krok ten jest niezbędny jeśli nie chcemy uzyskać  komunikatu o niezdefiniowanej metodzie WinMain16 w naszym kodzie.</p>
<p>Możemy lecz nie musimy, ponieważ w naszym prostym przykładzie możemy zrobić również tak:</p>
<pre class="geshi"><span style="color:#339900;">#include &#60;windows.h&#62;</span>
<span style="color:#339900;">#include &#60;SDL/SDL.h&#62;</span>
<span style="color:#339900;">#include &#60;memory.h&#62;</span>
<span style="color:#ff0000;">//#undef main</span>

<span style="color:#ff0000;">//int main(){</span>
<span style="color:#0000cc;">int</span> WINAPI WinMain <span style="color:#000000;">(</span>HINSTANCE hThisInstance,
                    HINSTANCE hPrevInstance,
                    LPSTR lpszArgument,
                    <span style="color:#0000cc;">int</span> cmd<span style="color:#000000;">)</span><span style="color:#000000;">{</span>

	SDL_Surface * cSurface;
	<span style="color:#0000cc;">if</span><span style="color:#000000;">(</span>SDL_Init<span style="color:#000000;">(</span>SDL_INIT_VIDEO<span style="color:#000000;">)</span> &#60; <span style="color:#0000dd;">0</span><span style="color:#000000;">)</span> <span style="color:#000000;">{</span>
		<span style="color:#0000dd;">printf</span><span style="color:#000000;">(</span><span style="color:#666666;">"SDL_Init error..<span style="font-weight:bold;color:#666666;">\n</span>"</span><span style="color:#000000;">)</span>;
		<span style="color:#0000cc;">return</span> <span style="color:#0000dd;">1</span>;
	<span style="color:#000000;">}</span>

	<span style="color:#0000dd;">atexit</span><span style="color:#000000;">(</span>SDL_Quit<span style="color:#000000;">)</span>;

	cSurface = SDL_SetVideoMode<span style="color:#000000;">(</span><span style="color:#0000dd;">1024</span>, <span style="color:#0000dd;">768</span>, <span style="color:#0000dd;">32</span>, SDL_ANYFORMAT<span style="color:#000000;">)</span>;

	<span style="color:#0000cc;">if</span><span style="color:#000000;">(</span>!cSurface<span style="color:#000000;">)</span> <span style="color:#000000;">{</span>
		<span style="color:#0000dd;">printf</span><span style="color:#000000;">(</span><span style="color:#666666;">"SDL_SetVideoMode error..<span style="font-weight:bold;color:#666666;">\n</span>"</span><span style="color:#000000;">)</span>;
		<span style="color:#0000cc;">return</span> <span style="color:#0000dd;">1</span>;
	<span style="color:#000000;">}</span>

	MSG messages;
	<span style="color:#0000dd;">memset</span><span style="color:#000000;">(</span>&#38;messages ,<span style="color:#0000dd;">0</span>,<span style="color:#0000dd;">sizeof</span><span style="color:#000000;">(</span>MSG<span style="color:#000000;">)</span><span style="color:#000000;">)</span>;

    <span style="color:#0000cc;">while</span> <span style="color:#000000;">(</span>GetMessage <span style="color:#000000;">(</span>&#38;messages, <span style="color:#0000cc;">NULL</span>, <span style="color:#0000dd;">0</span>, <span style="color:#0000dd;">0</span><span style="color:#000000;">)</span><span style="color:#000000;">)</span>
    <span style="color:#000000;">{</span>
        TranslateMessage<span style="color:#000000;">(</span>&#38;messages<span style="color:#000000;">)</span>;
        DispatchMessage<span style="color:#000000;">(</span>&#38;messages<span style="color:#000000;">)</span>;
    <span style="color:#000000;">}</span>

    <span style="color:#0000cc;">return</span> messages.<span style="color:#bb00cc;">wParam</span>;
}</pre>
<p>lub nawet tak:</p>
<pre class="geshi"><span style="color:#339900;">#include &#60;windows.h&#62;</span>
<span style="color:#339900;">#include &#60;SDL/SDL.h&#62;</span>
<span style="color:#ff0000;">//#include &#60;memory.h&#62;</span>
<span style="color:#ff0000;">//#undef main</span>

<span style="color:#ff0000;">//int main(){</span>
<span style="color:#0000cc;">int</span> WINAPI WinMain <span style="color:#000000;">(</span>HINSTANCE hThisInstance,
                    HINSTANCE hPrevInstance,
                    LPSTR lpszArgument,
                    <span style="color:#0000cc;">int</span> cmd<span style="color:#000000;">)</span><span style="color:#000000;">{</span>

	SDL_Surface * cSurface;
	<span style="color:#0000cc;">if</span><span style="color:#000000;">(</span>SDL_Init<span style="color:#000000;">(</span>SDL_INIT_VIDEO<span style="color:#000000;">)</span> &#60; <span style="color:#0000dd;">0</span><span style="color:#000000;">)</span> <span style="color:#000000;">{</span>
		<span style="color:#0000dd;">printf</span><span style="color:#000000;">(</span><span style="color:#666666;">"SDL_Init error..<span style="font-weight:bold;color:#666666;">\n</span>"</span><span style="color:#000000;">)</span>;
		<span style="color:#0000cc;">return</span> <span style="color:#0000dd;">1</span>;
	<span style="color:#000000;">}</span>

	<span style="color:#0000dd;">atexit</span><span style="color:#000000;">(</span>SDL_Quit<span style="color:#000000;">)</span>;

	cSurface = SDL_SetVideoMode<span style="color:#000000;">(</span><span style="color:#0000dd;">1024</span>, <span style="color:#0000dd;">768</span>, <span style="color:#0000dd;">32</span>, SDL_ANYFORMAT<span style="color:#000000;">)</span>;

	<span style="color:#0000cc;">if</span><span style="color:#000000;">(</span>!cSurface<span style="color:#000000;">)</span> <span style="color:#000000;">{</span>
		<span style="color:#0000dd;">printf</span><span style="color:#000000;">(</span><span style="color:#666666;">"SDL_SetVideoMode error..<span style="font-weight:bold;color:#666666;">\n</span>"</span><span style="color:#000000;">)</span>;
		<span style="color:#0000cc;">return</span> <span style="color:#0000dd;">1</span>;
	<span style="color:#000000;">}</span>

<span style="color:#000000;">   SDL_Event event;</span>

<span style="color:#0000cc;">   while</span><span style="color:#000000;">(</span><span style="color:#0000cc;">true</span><span style="color:#000000;">)</span> <span style="color:#000000;">{</span><span style="color:#0000cc;">
      if</span><span style="color:#000000;">(</span>SDL_PollEvent<span style="color:#000000;">(</span>&#38;event<span style="color:#000000;">)</span><span style="color:#000000;">)</span> <span style="color:#000000;">{</span>
<span style="color:#0000cc;">         if</span><span style="color:#000000;">(</span>event.<span style="color:#bb00cc;">type</span>==SDL_QUIT &#124;&#124; event.<span style="color:#bb00cc;">type</span>==SDL_KEYDOWN<span style="color:#000000;">)</span>
<span style="color:#0000cc;">            return</span> <span style="color:#0000dd;">0</span>;
<span style="color:#000000;">      }</span>

      SDL_Delay<span style="color:#000000;">(</span><span style="color:#0000dd;">100</span><span style="color:#000000;">)</span>;	<span style="color:#ff0000;">//oszczedz troche CPU</span>
<span style="color:#000000;">   }</span>
<span style="color:#000000;">}</span></pre>
<p>W tym drugim przypadku do obsługi zdarzeń wykorzystujemy SDL, a konkretnie obiekt klasy SDL_Event.<br />
W efekcie powinniśmy uzyskać nowe okienko o zadanych rozmiarach wypełnione czarnym kolorem..</p>
<p style="text-align:center;"><a href="http://zenedith.wordpress.com/files/2008/08/sdl_app.jpg"><img class="alignnone size-thumbnail wp-image-98" src="http://zenedith.wordpress.com/files/2008/08/sdl_app.jpg?w=123" alt="" width="123" height="96" /></a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[JNI #1 - Eclipse + CDT + MinGW]]></title>
<link>http://zenedith.wordpress.com/?p=39</link>
<pubDate>Wed, 23 Jul 2008 20:40:22 +0000</pubDate>
<dc:creator>zenedith</dc:creator>
<guid>http://zenedith.pl.wordpress.com/2008/07/23/jni-eclipse-cdt-mingw/</guid>
<description><![CDATA[Pisałem już o różnych językach skryptowych - postaram się opisać przynajmniej podstawy wspó]]></description>
<content:encoded><![CDATA[<p>Pisałem już o różnych językach skryptowych - postaram się opisać przynajmniej podstawy współpracy z cpp z każdym z nich. Dziś przedstawię jak wygląda współpraca Javy i cpp przez interfejs <em>JNI (Java Native Interface)</em>.</p>
<p>Tak jak w temacie, pokażę jak napisać prosty pomost między Javą a cpp przy wykorzystaniu IDE <em>Eclipse </em>z biblioteką <em><a href="http://www.eclipse.org/cdt/" target="_blank">CDT5.0</a></em> oraz wykorzystując toolchain'a <em>MinGW</em>. O sposobie konfiguracji takiego środowiska wspomniałem już <a href="http://zenedith.wordpress.com/2008/07/02/cpp-ide-eclipse-mingw/">wcześniej</a>, a więc zaczynamy.<!--more--></p>
<p>Naszym zadaniem będzie napisanie kodu w Javie, który będzie wykorzystywał dll'ke, którą przygotujemy wykorzystując język cpp i toolchain'a <em>MinGW </em>- będziemy przesyłać i odbierać dane z dll'a.</p>
<p>Lista wymagań jest następująca:</p>
<ol>
<li><em>Eclipse + CDT + MinGW</em>,</li>
<li><em>Java JDK</em> (nie musi być koniecznie nowe), <em>JRE </em>nie wystarczy.</li>
</ol>
<p>Ze wspomnianego <em>JDK </em>wykorzystamy następujące rzeczy:</p>
<ul>
<li><strong>bin\javah.exe</strong> - pozwoli automatycznie wygenerować nagłówek języka cpp(.h) dla danej klasy Javy,</li>
<li><strong>include\jni.h</strong> - dostarcza "funkcje" do konwersji typów Java &#60;-&#62; cpp oraz wiele innych,</li>
<li><strong>include\</strong>$<em>platform</em>$ - $<em>platform</em>$ w moim przypadku to win32.</li>
</ul>
<p>Kolejne kroki które będziemy wykonywać przedstawiają się następująco:</p>
<ol>
<li>napisanie kodu klas(y) w Javie z użyciem słowa kluczowego <strong>native</strong>,</li>
<li>kompilacja klas(y) - otrzymujemy pliki .<em>class</em>,</li>
<li>wygenerowanie nagłówka dla języka cpp (.h) za pomocą narzędzia <strong>javah.exe</strong>,</li>
<li>implementacja wygenerowanego pliku nagłówkowego w projekcie w języku cpp,</li>
<li>skompilowanie kodu do postaci pliku biblioteki dynamicznej (dll/so),</li>
<li>uruchomienie aplikacji Javy.</li>
</ol>
<p>Zaczynamy - punkt 1 i napisanie kodu klasy w Javie.<br />
Jak już wspomniałem, użyjemy słowa kluczowego <strong>native</strong> do oznaczenia metod, które chcielibyśmy zaimplementować w języku cpp.</p>
<p>Niech za przykład takiego kodu w Javie posłuży nam następująca klasa:</p>
<pre class="geshi"><span style="font-weight:bold;color:#000000;">public</span> <span style="font-weight:bold;color:#000000;">class</span> SomeData <span style="color:#66cc66;">{</span>

<span style="font-weight:bold;color:#000000;">native</span> <a href="http://www.google.com/search?hl=en&#38;q=allinurl%3AString+java.sun.com&#38;bntI=I%27m%20Feeling%20Lucky"><span style="font-weight:bold;color:#aaaadd;">String</span></a> GetVersion<span style="color:#66cc66;">(</span><span style="color:#66cc66;">)</span>;
<span style="font-weight:bold;color:#000000;">native</span> <span style="color:#993333;">void</span> SetVersion<span style="color:#66cc66;">(</span><a href="http://www.google.com/search?hl=en&#38;q=allinurl%3AString+java.sun.com&#38;bntI=I%27m%20Feeling%20Lucky"><span style="font-weight:bold;color:#aaaadd;">String</span></a> sNewVersion<span style="color:#66cc66;">)</span>;
<span style="font-weight:bold;color:#000000;">native</span> <span style="color:#993333;">void</span> DoSomething<span style="color:#66cc66;">(</span><span style="color:#66cc66;">)</span>;

<span style="font-weight:bold;color:#000000;">static</span><span style="color:#66cc66;">{</span>

<a href="http://www.google.com/search?hl=en&#38;q=allinurl%3ASystem+java.sun.com&#38;bntI=I%27m%20Feeling%20Lucky"><span style="font-weight:bold;color:#aaaadd;">System</span></a>.<span style="color:#006600;">loadLibrary</span><span style="color:#66cc66;">(</span><span style="color:#ff0000;">"libjni_test"</span><span style="color:#66cc66;">)</span>;

<span style="color:#66cc66;">}</span>

<span style="font-weight:bold;color:#000000;">public</span> <a href="http://www.google.com/search?hl=en&#38;q=allinurl%3AString+java.sun.com&#38;bntI=I%27m%20Feeling%20Lucky"><span style="font-weight:bold;color:#aaaadd;">String</span></a> GetSomeDataFromJava<span style="color:#66cc66;">(</span><span style="color:#66cc66;">)</span><span style="color:#66cc66;">{</span>

<span style="font-weight:bold;color:#000000;">return</span> <span style="color:#ff0000;">"dane z javy"</span>;

<span style="color:#66cc66;">}</span>

<span style="font-weight:bold;color:#000000;">public</span> <span style="font-weight:bold;color:#000000;">static</span> <span style="color:#993333;">void</span> main<span style="color:#66cc66;">(</span><a href="http://www.google.com/search?hl=en&#38;q=allinurl%3AString+java.sun.com&#38;bntI=I%27m%20Feeling%20Lucky"><span style="font-weight:bold;color:#aaaadd;">String</span></a><span style="color:#66cc66;">[</span><span style="color:#66cc66;">]</span> args<span style="color:#66cc66;">)</span> <span style="color:#66cc66;">{</span>

SomeData cData = <span style="font-weight:bold;color:#000000;">new</span> SomeData<span style="color:#66cc66;">(</span><span style="color:#66cc66;">)</span>;
<a href="http://www.google.com/search?hl=en&#38;q=allinurl%3ASystem+java.sun.com&#38;bntI=I%27m%20Feeling%20Lucky"><span style="font-weight:bold;color:#aaaadd;">System</span></a>.<span style="color:#006600;">out</span>.<span style="color:#006600;">println</span><span style="color:#66cc66;">(</span><span style="color:#ff0000;">"Version: "</span>+cData.<span style="color:#006600;">GetVersion</span><span style="color:#66cc66;">(</span><span style="color:#66cc66;">)</span><span style="color:#66cc66;">)</span>;

<span style="color:#66cc66;">}</span>

<span style="color:#66cc66;">}</span></pre>
<p>Parę słów komentarza: na początku mamy metody natywne, które będziemy implementować w cpp - podajemy więc ich definicję i na tym kończymy. Następnie widoczny jest blok static{} w którym podajemy informację do <em>JVM</em>, z jakiej dokładnie biblioteki dll/so będziemy korzystać.<br />
Ważne są dwie rzeczy:</p>
<ol>
<li><strong>nie podajemy tam rozszerzenia pliku</strong> (bez dll/so) ponieważ w zależności od systemu <em>JVM </em>zrobi to za nas,</li>
<li><strong>nie musimy ładowania biblioteki zewnętrznej umieszczać w bloku static{} </strong>- równie dobrze można to zrobić zaraz na początku metody <em>main(String[] args)</em>.</li>
</ol>
<p>Ostatecznie w metodzie <em>main(String[] args)</em> wywołujemy naszą natywną metodę w celu sprawdzenia efektu.</p>
<p>Czas na punkt 2 z listy czyli kompilację - tak naprawdę dzieje się ona z automatu jeśli mamy w <em>Eclipse</em> ustawioną opcję automatycznego kompilowania przy zapisywaniu pliku. Jeśli więc utworzyliśmy prosty projekt Javy, to plik źródłowy (.<em>java</em>) znajduje się w katalogu <strong>/src/</strong> a skompilowana klasa w katalogu <strong>/bin/</strong>.</p>
<p>W punkcie następnym użyjemy generatora nagłowka (.h) - narzędzia <em>javah.exe</em>. Jeśli jest on w naszej zmiennej środowiskowej <em>PATH </em>to wydanie polecania:</p>
<p><strong>javah -jni <em>$nasza_klasa$</em></strong></p>
<p>w katalogu <strong>\src\</strong> powinno zakończyć się sukcesem i wygenerowanym nagłówkiem, lecz może być jeszcze konieczne przekopiowanie pliku skompilowanego (.<em>class</em>) z katalogu <strong>\bin\</strong> do <strong>\src\</strong>.<br />
Natomiast jeśli wydanie powyższego polecania zgłasza błąd nieznanego polecenia, należy edytować zmienną <em>PATH </em>(np. z poziomu właściwości mój komputer, na zakładce Zaawansowane, przycisk zmienne środowiskowe, dodając dodatkowy wpis do zmiennej <em>PATH</em>, który będzie zawierał ścieżkę do pliku wykonywalnego <em>java, javac, javah, itp.</em> - np. <em>D:\Program Files\Java\jdk1.6.0_06\bin\</em> - <strong>należy uważać żeby nie nadpisać jej całkowicie a tylko dopisać</strong> dodając średnik jeśli to konieczne do oddzielenia ścieżek).</p>
<p>W tym momencie mamy już wygenerowany plik nagłówkowy więc możemy w <em>Eclipse</em> opcjonalnie przełączyć perspektywę na C/C++ i utworzyć projekt C++ (<strong>New C++ Project</strong>) - również pisałem już o tym <a href="http://zenedith.wordpress.com/2008/07/02/cpp-ide-eclipse-mingw/">wcześniej</a>, najważniejsze żeby dostępny był toolchain <em>MinGW </em>oraz rodzaj projektu wybrać <em>Empty Project </em>(.exe) ewentualnie docelowy <em>Shared Library</em>.</p>
<p style="text-align:center;"><a href="http://zenedith.wordpress.com/files/2008/07/perspective.jpg"><img class="alignnone size-thumbnail wp-image-49" src="http://zenedith.wordpress.com/files/2008/07/perspective.jpg?w=128" alt="" width="128" height="77" /></a> <a href="http://zenedith.wordpress.com/files/2008/07/new_cpp_project.jpg"><img class="alignnone size-thumbnail wp-image-50" src="http://zenedith.wordpress.com/files/2008/07/new_cpp_project.jpg?w=128" alt="" width="128" height="76" /></a> <a href="http://zenedith.wordpress.com/files/2008/07/project_type.jpg"><img class="alignnone size-thumbnail wp-image-51" src="http://zenedith.wordpress.com/files/2008/07/project_type.jpg?w=86" alt="" width="86" height="96" /></a></p>
<p>Po utworzeniu pustego projektu, należy dokonać na starcie paru ustawień - przechodzimy do jego właściwości:</p>
<ul>
<li>na zakładce <strong>C/C++ Bulid</strong> przechodzimy do <strong>Settings/Tool Settings</strong>,</li>
<li>przechodzimy do <strong>GCC C++ Compiler</strong> i dalej do <strong>Directories</strong>,</li>
<li>klikając przycisk dodajemy katalogi <strong>\include</strong> i <strong>\include\win32</strong> - (w moim przypadku są to <em>D:\Program Files\Java\jdk1.6.0_06\include</em> oraz <em>D:\Program Files\Java\jdk1.6.0_06\include\win32</em>)</li>
<li>zatwierdzamy wprowadzone zmiany,</li>
<li>następnie odnajdujemy zakładkę <strong>MinGW C++ Linker</strong>, która jest na poziomie <strong>C/C++ Bulid</strong>,</li>
<li>przechodzimy do zakładki <strong>Miscellaneous </strong>i w <strong>Linker Flags</strong> wpisujemy:<br />
<strong>-Wl,--add-stdcall-alias</strong><br />
<strong>Bardzo istotna opcja</strong>, ponieważ dzięki niej nie dojdzie do "udziwnienie" metod w wynikowym pliku biblioteki dynamicznej. Gdybyśmy o tej opcji zapomnieli, to pomimo że nasza biblioteka byłaby widoczna, to <em>JVM </em>nie odnalazłaby w niej określonych nazw, właśnie przez te "udziwnienia", tworzone przez linker z toolchain'a <em>MinGW</em>.</li>
<li>sprawdzamy jeszcze, czy na zakładce poniżej <strong>Miscellaneous-Shared Library Settings</strong> zaznaczona jest pierwsza opcja od góry <strong>Shared</strong> (jeśli tworzony był <em>Empty Project </em>trzeba ją zaznaczyć),</li>
<li>opcjonalnie, jeśli korzystaliśmy z <em>Empty Project </em>musimy zmienić ustawienia generowania pliku wykonywalnego na generowania dll/so - uczynimy to zmieniając zakładkę <strong>Tool Settings</strong> na <strong>Build Artifact</strong> i ustawiając pole <strong>Artifact Type</strong> na <strong>Shared Library</strong>. Resztę opcji możemy tak pozostawić chyba że pragniemy dla przykładu nadać jakąś specyficzną nazwę dla biblioteki dynamicznej.</li>
<li>zatwierdzamy wprowadzone zmiany i powracamy do ekranu głównego.</li>
</ul>
<p style="text-align:center;"><a href="http://zenedith.wordpress.com/files/2008/07/properties.jpg"><img class="alignnone size-thumbnail wp-image-53" src="http://zenedith.wordpress.com/files/2008/07/properties.jpg?w=56" alt="" width="56" height="96" /></a> <a href="http://zenedith.wordpress.com/files/2008/07/tools_settings.jpg"><img class="alignnone size-thumbnail wp-image-54" src="http://zenedith.wordpress.com/files/2008/07/tools_settings.jpg?w=102" alt="" width="102" height="96" /></a> <a href="http://zenedith.wordpress.com/files/2008/07/artifact1.jpg"><img class="alignnone size-thumbnail wp-image-56" src="http://zenedith.wordpress.com/files/2008/07/artifact1.jpg?w=102" alt="" width="102" height="96" /></a></p>
<p>Teraz możemy zaimportować wygenerowany przez javah plik nagłówkowy (<em>import/File System/</em>podajemy scieżkę do wygenerowanego pliku nagłówkowego). Gdy spróbujemy ten plik podejrzeć,  include jni.h nie powinien zgłaszać błędów (w p.p sprawdź <em>include directory</em>), lecz syntax error'y pojawią się przy wszystkich liniach rozpoczynających się np. tak <em>JNIEXPORT jstring JNICALL</em>, czyli wszystkich eksportowanych metodach z/do Javy - nie musimy się tym w ogóle przejmować.</p>
<p>Teraz należy utworzyć plik implementacji zaimportowanego pliku nagłówkowego czyli wkraczamy w punkt 4 - dodajemy w nim include'y dla pliku nagłówkowego i jni.h oraz kopiujemy definicje metod z pliku nagłówkowego i uzupełniamy je o nazwy zmiennych w metodach(są tylko typy) oraz ciało metod.</p>
<p>Dla przykładu podam ciało metody zwracającej z dll'ki napis typu String:<br />
<code><br />
</code></p>
<pre class="geshi">JNIEXPORT jstring JNICALL Java_SomeData_GetVersion<span style="color:#000000;">(</span>JNIEnv * env, jobject o<span style="color:#000000;">)</span><span style="color:#000000;">{</span>
<span style="color:#0000cc;">const</span> <span style="color:#0000cc;">char</span> *str = <span style="color:#666666;">"1.1 MinGW compiled"</span>;
<span style="color:#0000cc;">return</span> env-&#62;NewStringUTF<span style="color:#000000;">(</span>str<span style="color:#000000;">)</span>;
<span style="color:#000000;">}</span></pre>
<p>Jak widać w powyższym, nie ma bezpośredniej konwersji typów między Javą i cpp, dlatego musimy się posługiwać metodami konwersji, które dostępne są przez odwołanie do <em>JNIEnv</em>, która jest tablicą metod pomocniczych.</p>
<p>Kompilujemy kod (<strong>Bulid Project</strong>) i jeśli wszystko dobrze wcześniej ustawiliśmy, otrzymamy w wyniku plik biblioteki dynamicznej o nazwie projektu z przedrostkiem lib lub podaną przy ustawieniach <em>Arifact name</em>, co kończy punkt 5.</p>
<p>Przed wykonaniem ostatniego punktu, czyli odpalenia aplikacji Javy, musimy w odpowiednim miejscu umieścić nasz plik wynikowy biblioteki dynamicznej. Możemy go umieścić w scieżkę wskazywanej przez <em>java.library.path</em> lub umieścić w wybranym miejscu i w ustawieniach projektu Javy - <strong>Java Build Path</strong>, rozwinąć zakładkę <strong>Source </strong>i edytować ostatnią pozycję o nazwie <strong>Native Library Location</strong>, wskazując folder gdzie znajduje się skompilowany dll/so.</p>
<p>Czas na wykonanie ostatniego kroku i uruchomienie (najszybciej w Eclipse z opcji Run As/Java application) kodu. W wyniku nie powinniśmy otrzymać błędu <strong>java.lang.UnsatisfiedLinkError</strong>, a jeśli się to zdarzy, to należy uważnie przejrzeć opisane wcześniej czynności.</p>
<p>W ten sposób kończę ten najdłuższy do tej pory wpis na blogu.<br />
Z takimi podstawami można już szybko ruszyć w dalszą drogę i poznawać możliwości <em>JNI</em>.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Python 2.5 and encryption -- PyCrypto under Windows]]></title>
<link>http://jintoreedwine.wordpress.com/?p=30</link>
<pubDate>Mon, 21 Jul 2008 01:39:35 +0000</pubDate>
<dc:creator>jintoreedwine</dc:creator>
<guid>http://jintoreedwine.pl.wordpress.com/2008/07/20/python-25-and-encryption-pycrypto-under-windows/</guid>
<description><![CDATA[[Edit: 8-13-08] - Upon request I have provided a link to an installer for PyCrypto-2.0.1 that is com]]></description>
<content:encoded><![CDATA[<p><em><strong>[Edit: 8-13-08] - Upon request I have provided a link to an installer for PyCrypto-2.0.1 that is compiled for Python 2.5. You can download it <a href="http://www.cs.moravian.edu/~mills/files/pycrypto-2.0.1.win32-py2.5.exe">here</a> . I didn't post it originally because I was not sure how long I could provide a link for. This one should be good for about a year ... :) .</strong></em></p>
<p><strong>Note: The steps listed here will only work on Python 2.5 and above as that is when they added support for allowing MinGW to compile code</strong></p>
<p>I mentioned in a <a href="http://jintoreedwine.wordpress.com/2008/07/05/python-and-publicprivate-key-encryption/">previous post</a> that I was looking for a way to get public/private key encryption in Python and I was having a bugger of a time until I found <a href="http://www.freenet.org.nz/ezPyCrypto/">ezPyCrypto</a>. I don't know if I have mentioned this before, but I have been an Linux user for about 4 years now. Specifically <a href="http://www.gentoo.org">Gentoo Linux </a>,and I would never run another OS now that I have been a Linux user. At any rate that's not the point of this post. Since the script I was developing had to run on Windows I needed to install <a href="http://www.amk.ca/python/code/crypto">PyCrypto</a> (it's a dependency for ezPyCrypto). Well this would be trivial except that PyCrypto has C code that needs to be compiled. There are binary builds on the PyCrypto site for both Python 2.3 and 2.4, but not 2.5 which I am running. I wasn't going to let this stop me however. The rest of this post will explain what you need to do in order to get PyCrypto working under Windows with Python 2.5. After completing this you will also be able to build your own installer that you could package with your scripts to let people who don't want to install a C compiler run your code :)</p>
<p>The first thing you are going to want to do is install <a href="http://www.mingw.org/">MinGW</a> . MinGW will give you a nice C and C++ compiler for Windows. Just follow the instructions on their site and you will be good to go. After you have MinGW installed you will probably want to add entries to the Windows PATH variable so that when you are in a terminal you will be able to directly access MinGW. [As a note I still run Windows XP so these instructions will be done with that in mind] Doing this is quite simple:</p>
<ol>
<li>Right Click My Computer --&#62; Properties --&#62; Advanced --&#62; Environment Variables.</li>
<li>You will see User and System variables. If you want all users to use MinGW edit the Path entry in there. Otherwise add a Path variable under User variables.</li>
<li>Go to the Path variable from step 2. Add an entry to the Path that points to MinGW's bin directory. For me this was "C:\MinGW\bin" but it all depends on where you installed MinGW. <strong>Note:</strong> Entires in Windows Environment variables are separated by ';'</li>
<li>Click ok a bunch of times</li>
</ol>
<p>While you are changing environment variables you will want to add the main directory for Python to your path. For me this was: "C:\Python25". This made my final User Path entry: "C:\MinGW\bin;C:\Python25"</p>
<p>Now that you are done changing environment variables you will want to reboot your computer so that Windows gets your changes. Really... you will regret it if you don't reboot!</p>
<p>Now download PyCrypto and unpackage it. This turned out to be problem enough because not many people keep programs around that open .tar.gz files. Since am a Linux user I just unpacked them in Linux and transferred them to Windows (I run Windows XP under VirtualBox ). However, if that is not an option you can download and install <a href="http://www.izarc.org/">IZarc Archiver</a>. IZarc has been my favorite [Windows] extraction tool for a long time and it supports just about every archive format imaginable.I would recommend extracting the contents of PyCrypto to your desktop. Now is when the first starts!</p>
<p>First, open up a terminal. We will only be using a few commands and you don't have to be a terminal wiz kid to do this. I normally open a terminal by going: Start --&#62; Run --&#62; "cmd" --&#62; Press Enter</p>
<p>Now that you have a terminal up you want get to the PyCrypto directory. To move between directories in the terminal we use the "cd" command.</p>
<pre style="border:1px solid #cccccc;background:#ece9d8 none repeat scroll 0 0;overflow:auto;display:block;white-space:pre;width:98%;line-height:1.4;margin:2em 0;padding:8px;"><code style="font-size:10pt;">cd PATH-GOES-HERE</code></pre>
<p>So, for example here is the command I used to get to where I had PyCrypto:</p>
<pre style="border:1px solid #cccccc;background:#ece9d8 none repeat scroll 0 0;overflow:auto;display:block;white-space:pre;width:98%;line-height:1.4;margin:2em 0;padding:8px;"><code style="font-size:10pt;">cd C:\Documents and Settings\Jinto\Desktop\pycrypto-2.0.1</code></pre>
<p>Of course that command will only work for you if your user name is Jinto and you extracted it to the desktop exactly like I did ;) So modify it to fit your needs. Once you are in the pycrypto directory do a quick:</p>
<pre style="border:1px solid #cccccc;background:#ece9d8 none repeat scroll 0 0;overflow:auto;display:block;white-space:pre;width:98%;line-height:1.4;margin:2em 0;padding:8px;"><code style="font-size:10pt;">dir /w</code></pre>
<p>To make sure you see files. Specially make sure setup.py is there. We need to run that setup script and tell it to build the libraries. To do this issue the following command:</p>
<pre style="border:1px solid #cccccc;background:#ece9d8 none repeat scroll 0 0;overflow:auto;display:block;white-space:pre;width:98%;line-height:1.4;margin:2em 0;padding:8px;"><code style="font-size:10pt;">python setup.py build -c mingw32</code></pre>
<p>If all goes well it should build without any troubles and all that is left is to install it by issuing the following command:</p>
<pre style="border:1px solid #cccccc;background:#ece9d8 none repeat scroll 0 0;overflow:auto;display:block;white-space:pre;width:98%;line-height:1.4;margin:2em 0;padding:8px;"><code style="font-size:10pt;">python setup.py install</code></pre>
<p>You should be all set to use PyCrypto now, or to install ezPyCrypto which uses PyCrypto. As a bonus feature if you are looking to make an executable installer for PyCrypto you can run the following command:</p>
<pre style="border:1px solid #cccccc;background:#ece9d8 none repeat scroll 0 0;overflow:auto;display:block;white-space:pre;width:98%;line-height:1.4;margin:2em 0;padding:8px;"><code style="font-size:10pt;">python setup.py bdist_wininst</code></pre>
<p>This will leave you with a .exe file located in the "dist" folder.</p>
<p>I hope this helps everyone get PyCrypto running under Windows. For those of you Linux users who think I am leaving you out check your distro specific respository system they probably already have a package for PyCrypto!</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Msys + makefiles + your editor]]></title>
<link>http://echogtgt.wordpress.com/?p=3</link>
<pubDate>Tue, 15 Jul 2008 13:39:07 +0000</pubDate>
<dc:creator>rdentato</dc:creator>
<guid>http://echogtgt.pl.wordpress.com/2008/07/15/3/</guid>
<description><![CDATA[How to marry an editor like Crimson Editor (or the Emerald Community version) with msys/mingw and ma]]></description>
<content:encoded><![CDATA[<p>How to marry an editor like <a href="http://www.crimsoneditor.com/">Crimson Editor</a> (or the <a href="http://www.emeraldeditor.com/">Emerald Community</a> version) with <a href="http://www.mingw.org/">msys/mingw</a> and makefiles?. For long time I simply switched back and forth between the msys window and CEDT, I don't know why I waited so long to make this integration but it has been a great time saver for me. I hope it will be for you as well.</p>
<p>By the way, this methods works with other editors as well. If you use <a href="http://www.pspad.com/">PSPad</a> you can easily adapt this explanations to it.</p>
<p>Create a batch file (<span style="font-family:courier new;">cedt_mk.bat</span>) with this one line:<br />
<span style="font-family:courier new;"><br />
C:/msys/1.0/bin/sh --login -c "cd '%1' ; cd `pwd`; make %2"<br />
</span><br />
and store it in the msys <span style="font-family:courier new;">/usr/bin</span> directory (<span style="font-family:courier new;">C:/msys/1.0/bin</span> in my installation).</p>
<p>This batch file starts the msys shell and sets up all the environment variables as if you had login, so if your makefile depends on variables you set on your .profile, it will work.<br />
It then goes to the directory specified by the first argument, where it expects to find a makefile, and makes the target specified by the second parameter.<br />
Note that the first cd will receive a path in MSDOS format (e.g. 'D:\projects') that the shell will convert to '/d/projects'. However there is a bug in msys when the UNIX path ends with '/'. To fix it a cd to the current directory (cd `pwd`) is needed</p>
<p>Now add a couple of "tools" to CEDT through the "Tools/Conf. User Tools...":</p>
[caption id="attachment_5" align="aligncenter" width="400" caption="Crimson Editor Tools menu"]<a href="http://echogtgt.files.wordpress.com/2008/07/menu.gif"><img class="size-full wp-image-5" src="http://echogtgt.wordpress.com/files/2008/07/menu.gif" alt="Crimson Editor Tools menu" width="400" height="274" /></a>[/caption]
<p>I defined two. The first one as "Make ..." that will prompt for the name of the target (second argument set to $(UserInput).</p>
[caption id="attachment_6" align="aligncenter" width="400" caption="Will ask for the target name"]<a href="http://echogtgt.files.wordpress.com/2008/07/tool1.gif"><img class="size-full wp-image-6" src="http://echogtgt.wordpress.com/files/2008/07/tool1.gif" alt="Will ask for the target name" width="400" height="322" /></a>[/caption]
<p>and the second one as "Make Selected" that will use the selected word as the name of the target (second argument set to $(CurWord).</p>
[caption id="attachment_7" align="aligncenter" width="400" caption="Target will be the current/selected word"]<a href="http://echogtgt.files.wordpress.com/2008/07/tool2.gif"><img class="size-full wp-image-7" src="http://echogtgt.wordpress.com/files/2008/07/tool2.gif" alt="Target will be the current/selected word" width="400" height="322" /></a>[/caption]
<p>I mapped them to F9 and Ctrl+F9 respectively.</p>
<p>Having set the first "Argument" and the "Initial Dir" to $(FileDir), the makefile used will be the one stored in the same directory of the current file. This may work or not for you depending on the structure of the directories in your project.<br />
I usually have a makefile for each directory in the project (src, test, docs, ...) but sometimes I use a single makefile in the root directory of the project. In that case setting the first argument of cedt_mk.bat to "$(FileDir)\.."  would have worked.  Of course one could play with the cedt_mk.bat script to add more intelligence to it. I will be happy to hear any improvement.</p>
<p>Having set to option "Capture Output", I will get all the error messages directly in the output pane of CEDT. If I only could jump directly the file/line when an error occurs ...</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[QT 4.4.0 + Visual Studio Integration ]]></title>
<link>http://fakguen.wordpress.com/?p=22</link>
<pubDate>Mon, 14 Jul 2008 16:04:40 +0000</pubDate>
<dc:creator>Ferhat Akgün</dc:creator>
<guid>http://fakguen.pl.wordpress.com/2008/07/14/qt-440-visual-studio-integration/</guid>
<description><![CDATA[Nach langer Zeit kommt nun wieder ein Blogeintrag von mir. Im heutigen Artikel werde ich über die b]]></description>
<content:encoded><![CDATA[<p>Nach langer Zeit kommt nun wieder ein Blogeintrag von mir. Im heutigen Artikel werde ich über die bekannte QT Bibliothek von Trolltech schreiben. Viele von uns sind aus finanziellen Gründen gezwungen die Open Source Version zu nutzen.</p>
<p>Die kommerzielle Version bringt zwar die automatische Integration in Visual Studio mit sich, dafür kostet diese Version einiges und ist nicht jedermanns Sache. Mit diesem Artikel will ich die Integration Schritt für Schritt so einfach wie möglich erklären.</p>
<p><em><strong>Vorbereitung</strong></em></p>
<p>Bevor wir mit der Integration überhaupt beginnen, wollen wir uns erstmal Vorbereiten. Falls sie schon das SP1 für Visual Studio installiert haben oder es demnächst installieren wollen benötigen wir das Hotfix KB930198. Der direkte Bezug von Microsoft ist nur bei der englischen Version von VS möglich. Nutzer der deutschen Version sind auf andere Quellen angewiesen. Unten in meinen Referenzen werdet ihr einen Link finden, wo ihr das Hotfix runterladen könnt. Als nächstes besorgt ihr euch QT. Achtet darauf, dass es die Open Source Version <strong>ohne</strong> Mingw ist e.g. qt-win-opensource-src-4.4.0.zip. Entpackt nun das runtergeladene Qt-Paket in ein Verzeichnis eurer Wahl e.g. <strong>D:\QT4</strong>.</p>
<p><em><strong>Umgebungsvariablen</strong></em></p>
<p>Jetzt wollen wir unserem Betriebssystem QT bekannt machen. Dafür müssen wir bestimmte Umgebungsvariablen setzen.</p>
<p>Dafür gehen wir zunächst in System rein. Erreichbar mit Superkey (Windowstaste) + Pause oder über die Systemsteuerung. Danach wechseln wir über den Erweitert-Reiter zu den Umgebungsvariablen. Unter Systemvariablen erstellen wir nun unsere Variablen mit den dazugehörigen Werten.</p>
<p>Hier verwende ich als Beispiel den Pfad D:\QT4, den müsst ihr bei euch natürlich anpassen.</p>
<p>QTDIR       <strong>D:\QT4</strong><br />
INCLUDE    <strong>%QTDIR%\include</strong><br />
LIB            <strong>%QTDIR%\lib</strong><br />
PATH        <strong>%QTDIR%\bin</strong></p>
<p><em><strong><br />
QT Installation </strong></em></p>
<p>Nachdem ihr QT entpackt und die Umgebungsvariablen gesetzt habt müsst ihr die "Visual Studio Command Prompt" öffnen. Das ist nichts anderes als die normale Windows Konsole nur angepasst an die Anforderungen von VS.</p>
<p>Die Konsole erreicht ihr über:</p>
<p><strong>Startmenü -&#62; Programme -&#62; Microsoft Visual Studio 2005 -&#62;<br />
Visual Studio Tools</strong></p>
<p>Nun wechselt ihr in euer QT Verzeichnis (cd %QTDIR%). Als nächstes müssen wir die Quelldateien konfigurieren bevor wir sie kompilieren können.</p>
<p>Dafür geben wir folgenden Befehl ein:</p>
<p><strong>configure -platform win32-msvc2005 -no-qt3support<br />
-qt-sql-odbc -qt-sql-sqlite -qt-zlib -qt-libpng</strong></p>
<p>Hier sagen wir <em>configure</em>, dass er die Dateien für eine win32 Platform mit VS2005 erzeugen soll. Ich verzichte absichtlich auf QT3. Falls ihr es brauchen solltet lasst einfach "-no-qt3support" weg. Die folgenden Parameter sind optional, daher könnt ihr sie auch weglassen.</p>
<p>Diese Konfiguration dauert nun ein Weilchen, holt euch währenddessen einen Kaffee......</p>
<p>So..ihr seid nun mit der Konfiguration fertig. Freut euch nicht zu früh, denn jetzt kommt <strong>nmake</strong>. Damit wird der Kompilierungsvorgang angestoßen. Dieser Vorgang wird viel länger dauern, daher empfehle ich euch währenddessen was anderes zu machen...<br />
So..damit seid ihr also auch fertig. Schön!</p>
<p>Macht euch nun am besten zwei Verknüpfungen auf euer Desktop. Diese zwei werdet ihr öfters brauchen. Zum einen gibt es da den QT Designer und die QT Hilfe. Beide werden euch ein QT-Leben lang begleiten.</p>
<p><strong>%QTDIR%\bin\designer.exe</strong></p>
<p><strong>%QTDIR%\doc\html\index.html</strong></p>
<p><em><strong><br />
Beispielprojekt</strong></em></p>
<p>Erzeugt euch zunächst ein neues leeres Win32-Projekt. Im Assistenten wählt ihr "leeres Projekt" und "Windows Anwendung".  Als erstes erzeugen wir uns die main.cpp, da sie unser Einstiegspunkt sein wird. Den Inhalt können wir zunächst leer lassen.</p>
<p>In diesem Beispiel soll unsere Anwendung  ein einfaches Fenster erzeugen, mehr nicht! Dies dürfte als Demonstration ausreichend sein.</p>
<p>Dafür legen wir nun eine C++ Klasse an. Wir nennen sie <strong>mywindow</strong>. Die Basisklasse ist die QMainWindow. Da VS QMainWindow noch nicht kennt, wird er meckern. Ignoriert einfach diese Meldung und klickt auf Ja. Nun habt ihr drei Dateien in eurem Projekt die main.cpp, mywindow.cpp und die mywindow.h.</p>
<p>Als nächstes wechselt ihr in die Projekteigenschaften. Hier wählt ihr als Konfiguration "Alle Konfigurationen" (linke obere Kombobox). Im linken Bereich des Fensters wechselt ihr zu C/C++ und fügt auf der rechten Seite bei "Zusätzliche Includeverzeichnisse"<br />
die Werte <strong>$(QTDIR)\include;</strong><strong>$(</strong><strong>QTDIR)\include\Qt;</strong></p>
<p>Als nächstes ist der Linker dran. Wie eben wechseln wir nun links zu Linker und fügen auf der rechten Seite bei "Zusätzliche Bibliotheksverzeichnisse" den Wert <strong>$(</strong><strong>QTDIR)\lib</strong> ein. Wir bleiben kurz noch bei Linker. Bevor wir fortfahren wechseln sie wieder die Auswahl in der Kombobox. Diesmal auf Debug.</p>
<p>Unter Linker werden sie "Eingabe" sehen. Wechseln sie dorthin und geben sie auf der rechten Seite bei "Zusätzliche Abhängigkeiten"<br />
die Werte <strong>qtmaind.lib QtGuid4.lib QtCored4.lib</strong> ein.</p>
<p>Genau die Selbe Option setzen wir auch für Release. Wechseln sie dafür die Auswahl in der Kombobox und wie eben unter Linker in Eingabe reingehen. Auf der rechten Seite bei "Zusätzliche Abhängigkeiten" die Werte <strong>qtmain.lib QtGui4.lib QtCore4.lib</strong> einfügen.</p>
<p>Bevor wir fortfahren, wollen wir zuerst mit dem QT Designer eine *.ui Datei erstellen. Diese enthält das zu erzeugende Fenster in XML Form. Erzeugen sie mit dem Designer ein einfaches Mainwindow aus der Vorlage und speichern es in das Projektverzeichnis.</p>
<p>Danach gehen wir in die Projektmappe und fügen die eben erzeugte *.ui Datei in unsere Ressourcen. Das bewältigen wir mit einem einfachen Rechtsklick auf Ressourcen und Hinzufügen -&#62; vorhandenes Element.</p>
<p>Da VS *.ui Dateien noch nicht kennt, müssen wir ihm sagen was er damit machen soll. Deshalb erzeugen wir eine Buildregel.</p>
<p><strong>Beispiel:</strong></p>
<p>Anzeigename: <strong>ui_regel</strong><br />
Dateiname:     <strong>ui_regel</strong><br />
Verzeichnis:   <strong>..\..\Eigene Dateien\Visual Studio 2005\Regeln</strong></p>
<p>Im gleichen Fenster klicken sie nun auf Buildregel hinzufügen. Im erscheinenden Fenster geben sie folgendes ein:</p>
<p>Befehlszeile:<br />
<strong>$(QTDIR)/bin/uic.exe "$(InputPath)" -o ui_$(InputName).h</strong><br />
Dateierw.:  <strong><br />
*.ui</strong><br />
Name:<br />
<strong>UI</strong><br />
Anzeigename:       <strong><br />
Kompiliere UI Datei (*.ui)</strong><br />
Ausführungsbe.:   <strong><br />
Erzeuge UI Datei ui\_\$(InputName).h</strong><br />
Ausgaben:<br />
<strong>ui_$(InputName).h</strong></p>
<p>Solche Regeln sollten sie in ein Regelverzeichnis abspeichern und es VS verfügbar machen, damit es dauerhaft an der definierten Stelle nach Regeln suchen kann.</p>
<p><strong>Extras -&#62; Optionen -&#62; Projekte und Projektmappen -&#62; [VC++-Projekteinstellungen]</strong></p>
<p>Auf der rechten Seite geben sie bei "Regeldatei-Suchpfade" das Verzeichnis an, wo VS nach Regeln suchen soll.</p>
<p><em><strong>Beispiel Source</strong></em></p>
<blockquote><p>//main.cpp</p>
<p>#include &#60;QApplication.h&#62;<br />
#include "mywindow.h"</p>
<p>int main(int argc,char **argv)<br />
{<br />
QApplication app(argc,argv);<br />
mywindow win;<br />
win.show();</p>
<p>return app.exec();<br />
}</p></blockquote>
<blockquote><p>//mywindow.h<br />
#pragma once<br />
#include "ui_mywindow.h"</p>
<p>class mywindow :<br />
public QMainWindow,Ui::MainWindow<br />
{<br />
Q_OBJECT<br />
public:<br />
mywindow(void);<br />
~mywindow(void);<br />
};</p></blockquote>
<blockquote><p>//myindow.cpp<br />
#include "mywindow.h"</p>
<p>mywindow::mywindow(void)<br />
{<br />
setupUi(this);<br />
}</p>
<p>mywindow::~mywindow(void)<br />
{<br />
}</p></blockquote>
<p><em><strong>MOC</strong></em></p>
<p>Bevor das Projekt gelinkt werden kann, sollten sie voher den Meta Object Compiler über unsere Header-Dateien laufen lassen. Zur Zeit müssen wir dies über einen unangenehmen Weg machen. Wir müssen in die Eigenschaften der jeweiligen Datei rein um einen Buildschritt zu definieren.</p>
<p>Befehlszeile:<br />
<strong>$(QTDIR)\bin\moc.exe "$(InputPath)" -o<br />
"$(InputDir)moc_$(InputName).cpp"</strong></p>
<p>Beschreibung:<br />
<strong>moc läuft auf $(InputName).h</strong></p>
<p><strong>Ausgaben:<br />
$(InputDir)moc_$(InputName).cpp</strong></p>
<p>Nach Fertigstellung kompilieren sie die jeweilige Datei mit einem Rechtsklick über die Projektmappe. Nach der Kompilierung sollte in unserem Projektverzeichnis nun eine neue Datei erscheinen. Die neue e.g. moc_mywindow.cpp fügen wir unserem Projekt hinzu.</p>
<p>Erst jetzt kann das Projekt erfolgreich gelinkt werden.</p>
<p><em><strong>Schlusswort</strong></em></p>
<p>Anhand dieses Artikels müssten sie nun in der Lage sein, die Integration erfolgreich durchzuführen. Demnächst werde ich paar nützliche Addins vorstellen und den Schritt mit dem moc etwas erleichtern (mit PREmoc automatisieren). Ausserdem kommt noch ein Artikel über die Bibliothek qwt, welche man zum plotten von Graphen nutzen kann.</p>
<p><em><strong>Referenzen</strong></em></p>
<p><strong><a href="http://mm-werkstatt.informatik.uni-augsburg.de/documents/tutorials/qt2005.pdf">QT 4.x Integration in Visual Studio 2005</a></strong></p>
<p><strong><a href="http://qtforum.de">QTFORUM</a></strong></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Lightning Round, Part I]]></title>
<link>http://js0n.com/2008/06/02/26/</link>
<pubDate>Mon, 14 Jul 2008 00:00:13 +0000</pubDate>
<dc:creator>js0n</dc:creator>
<guid>http://js0n.com/?p=26</guid>
<description><![CDATA[A problem that I&#8217;ve had keeping this blog is that I&#8217;m constantly finding lots of links t]]></description>
<content:encoded><![CDATA[<p>A problem that I've had keeping this blog is that I'm constantly finding lots of links that I find interesting and I invariably start a post about it which does not end up getting finished.  So, in the interest of clearing off a number of the unfinished posts that have been sitting in my Wordpress account, I present the following:</p>
<p><a href="http://www.mingw.org/">http://www.mingw.org</a></p>
<blockquote><p><span class="bold">MinGW:</span> A collection of freely available       and freely distributable Windows specific header files and import       libraries combined with GNU toolsets that allow one to produce native       Windows programs that do not rely on any 3rd-party C runtime DLLs.</p>
<p><span class="bold">MSYS:</span> A contraction of "Minimal SYStem",       MSYS is a POSIX-like command line interpreter system, (CLI), offered       as an alternative to the Windows Command Prompt, (a.k.a. cmd.exe).       Conceived to facilitate the execution of the POSIX style build scripts       commonly provided by Open Source projects, and to interpret the Makefiles       which they generate, its CLI interprets the Bourne Shell command language,       in order to execute the commands commonly invoked by such scripts.</p></blockquote>
<p><a href="http://www.boost.org/development/tests/trunk/developer/summary.html" target="_blank">http://www.boost.org/development/tests/trunk/developer/summary.html</a></p>
<blockquote><p>This appears to be a list of the statuses of various libraries within the Boost library.  I don't recall why I was checking this out.</p></blockquote>
<p><a href="http://www.research.att.com/~bs/compilers.html" target="_blank">http://www.research.att.com/~bs/compilers.html</a></p>
<blockquote><p>This page written by Bjarne Stroustrup contains a short list of compilers for C++ as well as references to other sites that contain information on various C++ compilers.</p></blockquote>
<p><a href="http://videolectures.net" target="_blank">http://videolectures.net</a></p>
<blockquote><p>This site contains a large number of interesting videos of university lectures; many of these videos are about topics in computer science.</p></blockquote>
<p><a href="http://pastebin.com/" target="_blank">http://pastebin.com</a></p>
<blockquote><p>This site was referenced in an IRC channel that I visited.  It allows you to post a block of code at a public url so it's easy to reference certain lines when you're talking to someone about it online.</p></blockquote>
<p><a href="http://www.ailab.si/orange/doc/ofb/c_basics.htm  http://aigamedev.com/archives" target="_blank">http://news.ycombinator.com/item?id=149317</a></p>
<blockquote><p>This seems to be a thread discussing some hardware hacking resources.  Here are some of the links they mention, if you don't feel like combing through the article:</p>
<ul>
<li><span class="comment"><span style="color:#000000;">[1]: <a rel="nofollow" href="http://www.sparkfun.com/">http://www.sparkfun.com</a></span> </span></li>
<li><span class="comment"><span style="color:#000000;">[3]: <a rel="nofollow" href="http://www.opencircuits.com/">http://www.opencircuits.com</a></span> </span></li>
<li><span class="comment"><span style="color:#000000;">[4]: <a rel="nofollow" href="http://www.hackaday.com/">http://www.hackaday.com/</a></span> </span></li>
<li><span class="comment"><span style="color:#000000;">[5]: <a rel="nofollow" href="http://www.makezine.com/">http://www.makezine.com</a></span></span></li>
<li><span class="comment"><span style="color:#000000;">[6]: <a rel="nofollow" href="http://digikey.com/">http://digikey.com</a> - Huge selection. Great if you know what you want.</span> </span></li>
<li><span class="comment"><span style="color:#000000;">[7]: <a rel="nofollow" href="http://octopart.com/">http://octopart.com/</a> - Electronic Component search engine</span></span></li>
</ul>
</blockquote>
<p><a href="http://www.ailab.si/orange/doc/ofb/c_basics.htm" target="_blank">http://www.ailab.si/orange/doc/ofb/c_basics.htm</a></p>
<blockquote><p>A beginner tutorial on how to use the Orange library; a cool library if you're interesting in data mining.</p></blockquote>
<p><a href="http://aigamedev.com/archives" target="_blank">http://aigamedev.com/archives</a></p>
<blockquote><p>Many awesome articles of topics in artificial intelligence for games, defnitely worth a look.</p></blockquote>
]]></content:encoded>
</item>
<item>
<title><![CDATA[CImg.h ]]></title>
<link>http://cogsciml.wordpress.com/?p=8</link>
<pubDate>Sun, 18 May 2008 00:49:35 +0000</pubDate>
<dc:creator>Brandon King</dc:creator>
<guid>http://cogsciml.pl.wordpress.com/2008/05/17/cimgh/</guid>
<description><![CDATA[If you get a wonderful error like the following one using MingW in windows&#8230;
||=== cimg, Debug ]]></description>
<content:encoded><![CDATA[<p>If you get a wonderful error like the following one using MingW in windows...</p>
<p>&#124;&#124;=== cimg, Debug ===&#124;<br />
C:\Documents and Settings\King\Desktop\cimg\CImg.h&#124;&#124;In member function `cimg_library::CImg&#60;T&#62;&#38; cimg_library::CImg&#60;T&#62;::RGBtoHSV()':&#124;<br />
C:\Documents and Settings\King\Desktop\cimg\CImg.h&#124;15581&#124;internal compiler error: in int_const_binop, at fold-const.c:1328&#124;<br />
&#124;&#124;=== Build finished: 1 errors, 0 warnings ===&#124;</p>
<p>Check your version of mingw by typing "C:\MingW\bin\g++.exe -v"... I had version "<span>gcc version 3.4.2 (mingw-special)". </span></p>
<p>After installing MinGW-5.1.4.exe (gcc version 3.4.5 (mingw-vista special r3)), the problem was fixed. I hope that helps. Searching for CImg.h internal compiler error: in int_const_binop, at fold-const.c, didn't turn up any results so I decided to blog about it.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[g++ (MinGW) installieren (und in UltraEdit einbinden)]]></title>
<link>http://techtab.wordpress.com/?p=6</link>
<pubDate>Wed, 14 May 2008 13:59:49 +0000</pubDate>
<dc:creator>mcodez</dc:creator>
<guid>http://techtab.pl.wordpress.com/2008/05/14/g-mingw-fur-ultraedit-installieren/</guid>
<description><![CDATA[Dieser Beitrag richtet sich an aller C++ Entwickler unter Windows, die mit IDM UltraEdit arbeiten; o]]></description>
<content:encoded><![CDATA[<p>Dieser Beitrag richtet sich an aller C++ Entwickler unter Windows, die mit IDM UltraEdit arbeiten; oder solche, die es werden wollen.</p>
<p><span style="text-decoration:underline;">Warum MinGW und UltraEdit?</span></p>
<p>UltraEdit ist ein Texteditor für Programmierer aus dem Hause IDM (<a title="IDM UltraEdit Webseite" href="http://www.ultraedit.com/" target="_blank">offizielle Website</a>). Der Vorteil bei UltraEdit ist, das er zwar ein mächtiger Texteditor für nahezu alle Bedürfnisse ist, aber dem Entwickler nicht am Code pfuscht. Das heißt Sie geben die Kontrolle über Ihre Projekte nicht aus der Hand und trotzdem wird in an vielen Stellen Arbeit abgenommen. So lässt sich zum Beispiel die Codevervollständigung aktivieren oder externe Programme (wie Compiler) einbinden. Natürlich gehören auch Lesezeichen, (auch eigene) Code-Vorlagen, Umgang mit Projekten und Einzeldateien, WebSearchToolbar, Verschlüsselung, FTP-Browser, eine anpass- und abspeicherbare Arbeitsoberfläche, Codebereinigung,  ... zum Lieferumfang.</p>
<p>MinGW ist ein Compilerpaket, dass veile Sprachen wie C/C++, JAVA, ... abdeckt. Im Grunde sind dort alle Werkzeuge der GNU-Compiler-Collection enthalten. Diese sind für jedes Linux-System verfügbar, weshalb das MinGW-Paket ausschließlich für Windows erhältlich ist. Neben dem Compiler Von Microsoft ist der g++ einer der am häufigsten genutzten Compiler für C/C++.</p>
<p><span style="text-decoration:underline;">MinGW installieren</span></p>
<p>Da die Installation von UltraEdit durch den Installationsassisten in Deutsch eigentlich sehr einfach ist und ohne Probleme ablaufen sollte, gehen wir im Folgenden davon aus, das dies bereits erledigt ist. Bleibt also noch MinGW. Die offizielle Website lautet <a title="http://www.mingw.org/" href="http://www.mingw.org/" target="_blank">http://www.mingw.org/</a>. Dort befindet sich auch ein Link zum <a title="Sourceforge-Acrhiv des MinGW-Projekts" href="http://sourceforge.net/project/showfiles.php?group_id=2435" target="_blank">Sourceforge-Archiv des MinGW-Projekts</a>, wo die Dateien heruntergeladen werden können. Wir nehmen hier den "Automated MinGW Installer".</p>
<p>Nach dem Dowload kann die .exe gestartet werden. Eine Meldung erscheint, das nach der aktuellsten version gesucht wird. Anscheinend erscheint die Meldung "Welcome to MinGW Version ...".</p>
<ol>
<li>Die Installation kann mit "Next &#62;" vorbereitet werden. Hier wählen wir "Download and install" um die benötigten Datien aus dem Internet zu laden und MinGW anschließend zu installieren.</li>
<li>MinGW kann nur isntalliert werden, wenn sie die nun sichtbare lizenz mit "I Agree" akzeptieren.</li>
<li>Bei der Frage,w elche Version wählen wir "Current". Es gibt in der regel keinen Grund ältere Sofwtare vorzuziehen. Aber eine ß-Version kann zu Problem führen. Weiter mit "Next &#62;".</li>
<li>Nun können Sie wählen welche Pakete installiert werden sollen. Zunächst reicht uns für die reine C++-Programmierung "MinGW Base Tools" und  "g++ Compiler". (Natürlich können Sie bei Bedarf weitere installieren.)</li>
<li>Nach "Next &#62;" können Sie nun ein Installatiosnverzeichnis wählen. Sie könne hier im Grunde ein beliebiges auswählen. allerdings verursachen Compiler manchmal Probleme, wenn in irgendeinem Pfad Leerzeichen sind. Es wäre also praktisch hierauf zu verzichten. Der Vorschlag ("C:\MinGW") ist also eine gute Idee.</li>
<li>Anschließend kann der Name für den Ordner im Startverzeichnis gewählt werden.</li>
<li>Nach dem Klick auf "Install" werden die benötigten Datien aus dem Internet geladen und die Installation startet.</li>
<li>Anschließend ein Klick auf "Next &#62;" und hier auf "Finish" und Sie haben es geschafft.</li>
</ol>
<p><span style="text-decoration:underline;">g++ ohne UltraEdit benutzen</span></p>
<p>g++ ist nun einsatzbereit. Sie sollten allerdings den Pfad zu MinGW noch als Umgebungsvariable setzen. Sonst müssen Sie beim Kompilieren immer den kompletten Pfad angaben.</p>
<ol>
<li>Gehen Sie in den Eintrag "System" in der Systemsteuerung. Hierfür muss die klassische Ansicht ausgewählt sein.</li>
<li>Nun gehen Sie auf den Reiter "Erweitert" und klciken auf den Button ganz unten "Umgebungsavriablen".</li>
<li>Unter "Systemvariablen" suchen Sie den Eintrag "Path".</li>
<li>Nach einem Doppelklick können Sie in das Feld "Wert der Variablen" den folgenden Text anhängen: ";C:\MinGW\bin" (ohne Anführungszeichen, gegebenenfalls müssen Sie den Pfad anpassen, wenn Sie ihr Installationsverzeichnis anders gewählt haben).</li>
<li>Damit die Umgebungsvariablen komplett übernommen werden, sollte der PC nun neugestartet werden.</li>
</ol>
<p>Wenn Sie nun eine .cpp-Datei kompilieren wollen, rufen Sie die Konsole auf (zum Beispiel mit [WIndows]+[E] und dort "cmd" (ohne Anführungszeichen) eingeben. Mit [Enter] bestätigen).</p>
<ol>
<li>wechseln Sie mit "cd" in das Verzeichnis, indem sich die .cpp-Datei befindet. Zum Beispiel: cd C:\dev\cpp</li>
<li>Hier geben Sie g++ -o MeinErstesProgramm MeinErsterCode.cpp ein (g++ -o [Name die die .exe haben soll] [Kompletter Name der Datei]).</li>
<li>Wenn Sie mehrere Dateien kompilieren wollen, können Sie anstatt "MeinErsterCode.cpp" auch "*.cpp" schreiben.</li>
</ol>
<p><span style="text-decoration:underline;">g++ in UltraEdit einbinden</span></p>
<p>Wenn Sie UltraEdit benutzen, können Sie sich die ganze Arbeit unter "g++ ohne UltraEdit benutzen" sparen. Hier gehen Sie einfach unter [Extras]-&#62;[Werkzeug-Konfiguration]. Anschließend auf "Einfügen". Nun können Sie die folgenden Werte eingeben:</p>
<ul>
<li>Bezeichnung für den Menüeintrag: aktuelle Datei kompilieren</li>
<li>Befehlszeile: C:\MinGW\bin\g++.exe -o "%n" %F</li>
<li>Arbeistverzeichnis: %P</li>
<li>(Nun im Reiter "Optionen") Programmtyp: Dos-Programm</li>
<li>Ein Harken bei "Aktive Datei erst speichern"</li>
<li>(Nun im Reiter "Ausgabe")Befehlsausgabe: Ausgabe in Listenfeld und Ausgabe aufzeichnen</li>
<li>Markierten Text ersetzen durch: Nicht ersetzen</li>
</ul>
<p>Wenn Sie ganze Projekte kompilieren möchten, müssen Sie im Gegensatz zu oben einige Einträge ändern:</p>
<ul>
<li>Bezeichnung für den Menüeintrag: Projekt kompilieren</li>
<li>Befehlszeile: C:\MinGW\bin\g++.exe -o "%rn" %RP*.cpp</li>
<li>Arbeistverzeichnis: %RP</li>
<li>Ein Harken bei "Erst alles speichern"</li>
</ul>
<p>Nun können Sie noch Einträge zum Ausführen der erstellen Programme einfügen. Wenn Sie die erstellte .exe einer Datei ausführen wollen, lautet die Befsehlszeile "%P%N.exe" (beim Projekt "%RP%RN.exe"). Unter Optionen wird nichts gespeichert und das DOS-Programm ausgewählt. Bei beiden Typen wird unter dem Reiter "Ausgabe" das Häkchen bei "Ausgabe aufzeichnen" entfernt und afür eins bei "DOS-Fenster anzeigen" gesetzt.</p>
<p>Mehr zu diesen Möglichkeiten bei UltraEdit finden Sie auch sehr gut dokumentiert in der Hilfe. Der Eintrag in der Hilfe ist gleichnamig mit dem genutzten im Extras-Menü.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Instalar GTK+ con MinGW en Code::Blocks sobre Windows]]></title>
<link>http://arrecis.wordpress.com/?p=58</link>
<pubDate>Sun, 13 Jul 2008 17:59:03 +0000</pubDate>
<dc:creator>Giovanni</dc:creator>
<guid>http://arrecis.pl.wordpress.com/2008/07/13/gtk-con-mingw-en-codeblocks-sobre-windows/</guid>
<description><![CDATA[&#8220;Al principio el hombre creo la máquina, y asi el hombre dejo de ser útil&#8221;, 
jajaja, a]]></description>
<content:encoded><![CDATA[<p><em>"Al principio el hombre creo la máquina, y asi el hombre dejo de ser útil", </em></p>
<p>jajaja, al menos todavía somos útiles o no??. Estuve buscando por un largo tiempo la forma para crear un interfaz gráfica para un mi proyectito que tengo en C++, considere utilizar la WinApi (la libreria para crear codigo Nativo de Windows), pero la verdad creo que aprender esa libreria llevaría mucho tiempo y tanto esfuerzo solo serviría para Windows y no para Linux, que tambien me interesa.</p>
<p>Segui buscando y encontré varias opciones,</p>
<p><em><strong>WxWidgets: </strong></em><a href="http://www.wxwidgets.org/" target="_blank">http://www.wxwidgets.org/</a></p>
<p><em><strong>Qt</strong></em>: <a href="http://trolltech.com/downloads/opensource" target="_blank">http://trolltech.com/downloads/opensource</a></p>
<p><em><strong>GTK+:</strong></em><a href="http://www.gtk.org/" target="_blank"> http://www.gtk.org/</a></p>
<p>¿Cual elegir?, Quizás algunas personas me contradigan en lo siguiente, pero yo pienso que esto es parecido a cuando uno elige su lado en alguno de los siguientes temas, la politica, el futbol y la religión, jajajaja, todos son correctos y a la vez todos equivocados, es cuestión de gustos, recuerden que lo que es fácil para alguno puede ser dificil para otro, asi que no podria venir y decir cual es más fácil, ni cual es más dificil.</p>
<p>Yo me decidi por GTK, senti facilidad para aprenderlas, hay gran cantidad de aplicaciones que la utilizan y su aspecto es muy bueno,  estas librerias estan muy apoyadas por una gran comunidad, ademas de ser compatibles para windows y linux, pero vuelvo a repetir, <em>"Es cuestión de gustos"</em>.</p>
<p>pero si les interesa utilizar GTK aqui les dejo un tutorial de como hacerlo utlizando el compilador MinGW con el IDE Code::Blocks sobre Windows.<a href="http://arrecis.files.wordpress.com/2008/07/gtk-con-mingw-en-codeblocks.pdf"></a></p>
<p style="text-align:right;">Para Descargar Tutorial <a href="http://arrecis.files.wordpress.com/2008/07/gtk-con-mingw-en-codeblocks.pdf">PRESIONAR AQUI.</a></p>
<p style="text-align:right;">
<p><img class="alignleft" src="http://swik.net/swikIcons/img-624-96x96.png" alt="" width="96" height="96" /></p>
<p style="text-align:center;"><img class="aligncenter" src="http://upload.wikimedia.org/wikipedia/commons/thumb/2/2d/GTK.svg/260px-GTK.svg.png" alt="" width="260" height="270" /></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[[Perl] Usando MinGW+Script para compilar com facilidade]]></title>
<link>http://dumpmind.wordpress.com/?p=4</link>
<pubDate>Wed, 09 Jul 2008 14:39:56 +0000</pubDate>
<dc:creator>colt7r</dc:creator>
<guid>http://dumpmind.pl.wordpress.com/2008/07/09/perl-mingw-compilar-com-facilidade-c/</guid>
<description><![CDATA[#!/usr/bin/perl
# Escrito por: Colt7r - 5/Abril/2008
# Contato: colt7r |@| bsdmail.org$mingw_path = ]]></description>
<content:encoded><![CDATA[<p><code>#!/usr/bin/perl<br />
# Escrito por: Colt7r - 5/Abril/2008<br />
# Contato: colt7r &#124;@&#124; bsdmail.org$mingw_path = $ENV{'SystemDrive'}."\\MinGW\\bin\\";<br />
$home = $ENV{'SystemDrive'}.$ENV{'HOMEPATH'}."\\Meus Documentos\\";print "Compilar e Mover usando MinGW (GCC Win32)\n";<br />
print "Escrito por Colt7r\n";<br />
print "\nDiretorio do MinGW: $mingw_path\n\n";<br />
compile:<br />
print 'Arquivo para ser compilado: ';<br />
chomp($compile = &#60;STDIN&#62;);<br />
if(!$compile) {<br />
goto compile;<br />
}<br />
output:<br />
print 'Output: ';<br />
chomp($output = &#60;STDIN&#62;);<br />
if(!$output) {<br />
goto output;<br />
}<br />
print "\n";<br />
system("cd $home &#38;&#38; copy $compile $mingw_path &#38;&#38; cd $mingw_path &#38;&#38; gcc $compile -o $output");<br />
system("cd $mingw_path &#38;&#38; copy \"$output\" \"$home\"");<br />
system("cd $mingw_path &#38;&#38; del $compile &#38;&#38; del $output");<br />
print "\nPronto!\n";<br />
system("pause &#62; nul");</p>
<p></code></p>
<p>Modifique a variável $mingw_path para o caminho do MinGW (Geralmente é C:\MinGW\bin).</p>
<p>O arquivo C deve estar em C:\Documents and Settings\Usuário\Meus Documentos, ou simplesmente 'Meus Documentos', a não ser que você modifique a variável $home.</p>
<p>Link para o script: <a title="http://dumpmind.pastebin.com/f2c038168" href="http://dumpmind.pastebin.com/f2c038168" target="_blank">http://dumpmind.pastebin.com/f2c038168</a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[CPP IDE = Eclipse + MinGW]]></title>
<link>http://zenedith.wordpress.com/?p=22</link>
<pubDate>Wed, 02 Jul 2008 15:29:59 +0000</pubDate>
<dc:creator>zenedith</dc:creator>
<guid>http://zenedith.pl.wordpress.com/2008/07/02/cpp-ide-eclipse-mingw/</guid>
<description><![CDATA[Ponieważ w poprzednim projekcie &#8220;Nikita - Tajemnica skarbu piratów&#8221; używałem środow]]></description>
<content:encoded><![CDATA[<p><img class="alignleft" style="margin-left:6px;margin-right:6px;" src="http://www.eclipse.org/downloads/images/c.jpg" alt="" width="62" height="69" />Ponieważ w poprzednim projekcie "Nikita - Tajemnica skarbu piratów" używałem środowiska Eclipse, postanowiłem krótko opisać, jak wykorzystać to świetne IDE do pracy z cpp zamiast Javy. Trzeba przyznać, że rozszerzalność tego IDE jest niesamowita - istnieje mnóstwo plugin'ów dzięki którym można wykorzystać Eclipse do programowania w większości języków kompilowanych oraz skryptowych.<!--more--></p>
<p>Potrzebne będą dwie rzeczy:</p>
<ol>
<li><a href="http://nuwen.net/mingw.html" target="_blank">Dystrybucja MinGW</a>,</li>
<li><a href="http://www.eclipse.org/downloads/packages/eclipse-ide-cc-developers/ganymeder" target="_blank">Eclipse + CDT</a> lub samo <a href="http://www.eclipse.org/cdt/downloads.php" target="_blank">CDT</a> do pobrania przez <em>update software</em> w Eclipse po dodaniu strony<br />
<em>http://download.eclipse.org/tools/cdt/releases/ganymede</em>.</li>
</ol>
<p>Wykorzystałem dystrybucję <a href="http://nuwen.net/mingw.html" target="_blank">MinGW Distro - nuwen.net</a>, ponieważ jest szybka w instalacji (rozpakowanie plików) i zawiera wszelkie podstawowe aplikacje oraz te bardziej specjalne, ale o tym można się dowiedzieć na podanej stronie.</p>
<p>Jeśli chodzi o <a href="http://www.eclipse.org/downloads/packages/eclipse-ide-cc-developers/ganymeder" target="_blank">Eclipse</a>, to jest to wersja specjalnie przygotowana do projektów w cpp i zawiera oprócz CDT (w wersji 5.0) także klienta repozytorium CVS (klienta SVN można ściągnąć ze strony <a href="http://subclipse.tigris.org/" target="_blank">subclipse.tigris.org</a>) oraz <a href="http://www.eclipse.org/mylyn/new/" target="_blank">Mylyn</a>.</p>
<p>Istotne jest to, jak należy "zainstalować" tą dystrybucję MinGW, żeby była widoczna dla Eclipse. Otóż możemy rozpakować podaną dystrybucję gdziekolwiek (najlepiej bez białych znaków w strukturze katalogów),  lecz jeśli nie będzie to standardowe miejsce <strong>C:\MinGW\</strong> to <strong>musimy</strong> utworzyć na dysku C takie katalogi: <strong>C:\MinGW\bin\</strong>, ponieważ CDT wyszukuje zainstalowanego <em>toolchain</em>'a od MinGW właśnie po istnieniu podanej ścieżki na dysku C.<br />
To oczywiście nie wszystko - w zmiennej PATH należy dodać lokalizację rozpakowanej dystrybucji ze ścieżką do podkatalogu <em>bin</em>, czyli dla przykładu <em>D:\PRO\MinGW\bin\</em>. Żeby sprawdzić czy wszystko jest ok, należy uruchomić ponownie komputer lub wylogować się z profilu - dopiero wtedy zmiany w PATH zostaną uwzględnione dla systemu (oczywiście można wszystko zmienić z wiersza polecenia ale nie będę komplikował).</p>
<p style="text-align:center;"><a href="http://zenedith.wordpress.com/files/2008/07/path.jpg"><img class="size-thumbnail wp-image-71 aligncenter" src="http://zenedith.wordpress.com/files/2008/07/path.jpg?w=128" alt="" width="128" height="78" /></a></p>
<p>W tym momencie należy sprawdzić, czy zmienna systemowa PATH zawiera dystrybucję MinGW - w tym celu wydajemy w konsoli systemu (cmd)  polecenie:<br />
<code><em>g++ -v</em></code>.<br />
Jeśli wszystko jest ok, to powinniśmy otrzymać parę linii komunikatu kończącego się np. tak:<br />
<em>gcc version 4.2.1-dw2 (mingw32-2)</em>.</p>
<p>Czas na odpalenie Eclipse  i stworzenie projektu.<br />
W tym celu wybieramy opcję <strong>New Project/C++ Project</strong> z menu kontekstowego nad oknem Project Explorer, przez przyciśnięcie przycisku na liście toolbox'a <strong>New C/C++ Project</strong> lub przez menu File.</p>
<p>W otworzonym okienku istotne są dwie rzeczy:</p>
<ol>
<li>W prawym panelu powinien być widoczny toolchain <strong>MinGW GCC</strong>,</li>
<li>Tworząc "zwykły" projekt .exe wybieramy <em>"Empty Project"</em>, zamiast pozostałych <em>"Hello World ..."</em>.</li>
</ol>
<p>Dalsze okienka akceptujemy bez wprowadzania zmian.</p>
<p style="text-align:center;"><a href="http://zenedith.wordpress.com/files/2008/07/project_type.jpg"><img class="alignnone size-medium wp-image-51" src="http://zenedith.wordpress.com/files/2008/07/project_type.jpg?w=271" alt="" width="271" height="300" /></a></p>
<p>Tworzymy nowy plik implementacji (.cpp)  z menu <em>new</em>, i dodajemy tam przykładowy kod:</p>
<pre class="geshi"><span style="color:#339900;">#include &#60;iostream&#62;</span>
<span style="color:#0000cc;">using</span> <span style="color:#0000cc;">namespace</span> std;

<span style="color:#0000cc;">int</span> main <span style="color:#000000;">(</span><span style="color:#000000;">)</span> <span style="color:#000000;">{</span>
<span style="color:#ff0000;">// Say Hello five times</span>
<span style="color:#0000cc;">for</span> <span style="color:#000000;">(</span><span style="color:#0000cc;">int</span> index = <span style="color:#0000dd;">0</span>; index &#60; <span style="color:#0000dd;">5</span>; ++index<span style="color:#000000;">)</span>
<span style="color:#0000dd;">cout</span> &#60;&#60; <span style="color:#666666;">"HelloWorld!"</span> &#60;&#60; endl;
<span style="color:#0000dd;">exit</span><span style="color:#000000;">(</span><span style="color:#0000dd;">0</span><span style="color:#000000;">)</span>;
<span style="color:#000000;">}</span></pre>
<p><code><br />
</code><br />
Domyślnie kompilacja następuje przy każdym save'owaniu - o ile przy programowaniu w Javi'e nie jest to uciążliwe (a wręcz bardzo pomocne), to w przypadku pracy z cpp może to przeszkadzać osobą takim jak ja, które wciskają <em>ctrl+s</em> co 20 sekund. Warto więc odznaczyć pole <em>"Build Automatically"</em> w menu <em>Project</em>.<br />
Kompilacji (build całego projektu) dokonywać teraz można np. poprzez skrót <em>ctrl+b</em> lub przez odpowiednią ikonkę "młotka" na toolbox'ie Eclipse'a.<br />
W odpowiedzi w oknie <em>Console</em> dostaniemy podobne podsumowanie:<br />
<code><br />
Build complete for project (twój projekt)<br />
Time consumed: 1578  ms.<br />
</code></p>
<p>Teraz wystarczy otrzymany .<em>exe </em>odpalić bezpośrednio z Eclipse przez menu <strong>Run as - Local C/C++ Application</strong> i w oknie <em>Console </em>otrzymamy wynik działania aplikacji podanej wyżej.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Code::Blocks &amp; WxWidgets, le retour...]]></title>
<link>http://enconstruction.wordpress.com/?p=9</link>
<pubDate>Mon, 30 Jun 2008 08:03:48 +0000</pubDate>
<dc: