{"id":18128,"date":"2012-12-20T09:59:24","date_gmt":"2012-12-20T14:59:24","guid":{"rendered":"http:\/\/www.shamusyoung.com\/twentysidedtale\/?p=18128"},"modified":"2012-12-20T10:24:06","modified_gmt":"2012-12-20T15:24:06","slug":"postcards-from-linux-part-2how-do-i-work-this","status":"publish","type":"post","link":"https:\/\/www.shamusyoung.com\/twentysidedtale\/?p=18128","title":{"rendered":"Postcards From Linux Part 2:<br\/>How Do I Work This?"},"content":{"rendered":"<p><table   class=\"\" cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/splash_linux.jpg' class='insetimage'   alt='splash_linux.jpg' title='splash_linux.jpg'\/><\/td><\/tr><\/table><\/p>\n<p>If I&#8217;m going to indulge this pipe-dream of Linux-using, then it&#8217;s time to stop fussing around in Minecraft and work on something serious. It&#8217;s time to see if I can use Linux to program. If I can&#8217;t do that, then I ought to walk away now before I get too comfortable.<\/p>\n<p>Going by the comments yesterday, it seems like <a href=\"http:\/\/en.wikipedia.org\/wiki\/Eclipse_(software)\" title=\"Eclipse - Wikipedia\">Eclipse<\/a> is the go-to IDE for coders on Linux. (IDE means &#8220;Integrated development environment&#8221;, and is to coding what a word processor is to writing) I open the  Software manager and install it. It seems to work fine, except&#8230;<\/p>\n<p><table width='600'  cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/linux_eclipse.jpg' class='insetimage' width='600' alt='Eclipse IDE for Linux Mint' title='Eclipse IDE for Linux Mint'\/><\/td><\/tr><\/table><\/p>\n<p>For a quick test, I input <a href=\"http:\/\/groups.engin.umd.umich.edu\/CIS\/course.des\/cis400\/c\/hworld.html\" title=\"Hello World!\">the classic Hello World program<\/a> to find that Eclipse can&#8217;t find &lt;stdio.h&gt;. This is very strange. I expected some confusion and growing pains in moving to Linux, although I didn&#8217;t expect them quite this soon or quite this simple. For completeness, I try <a href=\"http:\/\/www.cplusplus.com\/doc\/tutorial\/program_structure\/\" title=\"Hello World C++\">the C++ variant of Hello World<\/a>, and discover that it doesn&#8217;t know what to make of &lt;iostream&gt;. <\/p>\n<p>This is such a basic, fundamental failure that I don&#8217;t know where to begin. Imagine if word processors would only let you use a word if it was in the dictionary. Now imagine a word processor that came without any dictionary. That&#8217;s what we have here. This is a C development environment that doesn&#8217;t know C.<\/p>\n<p>Is this a problem with Eclipse? A problem with my Linux install? A problem with how I set up this project? I don&#8217;t know, and so I don&#8217;t know where to look for answers. In bemused frustration (yes that&#8217;s possible) I turn to Twitter. My tweeps suggest that <a href=\"http:\/\/www.codeblocks.org\/\" title=\"code::blocks IDE\">code::blocks<\/a> is a good IDE to use. So I install that.<\/p>\n<p><!--more-->Installing code::blocks also manages to install whatever files were missing and preventing Eclipse from working properly. This is the first sign that we&#8217;re not in Kansas anymore, Toto. In Windows, programs tend to keep to themselves. If I install Visual Studio, it will install &lt;stdio.h&gt;, &lt;iostream&gt;, and the thousands of other files that a compiler needs. If I then install (say) Qt Creator, it will need its very own copy of those files &#8211; <em>even if the files are identical, down to the last character<\/em>. There are situations where Windows programs share, but generally not stuff like this. Eclipse and code::blocks are obviously drawing from the same pool of files.<\/p>\n<p><table width='600'  cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/linux_code_blocks.jpg' class='insetimage' width='600' alt='Code::Blocks IDE for Linux Mint' title='Code::Blocks IDE for Linux Mint'\/><\/td><\/tr><\/table><\/p>\n<p>So now I have two IDEs working. I have decided to keep them both for now, and pit them against one another. The one that confuses \/ irritates \/ hassles me the least will be the winner and become my IDE of choice. The other one will&#8230; actually, no. I don&#8217;t dare uninstall the loser, lest it take those shared files with it to oblivion. So the loser will remain installed and I&#8217;ll just have to remember to make a point of not clicking on it. That&#8217;ll teach it.<\/p>\n<p>Well, I&#8217;ve compiled Hello World, which is satisfying but not productive. If we&#8217;re going to write real code then we&#8217;ll need real tools. We might as well solve the most difficult problem first: Window management and portability. Based on the suggestions yesterday, I&#8217;ve decided to build a little test application on <a href=\"http:\/\/www.gtk.org\/\" title=\"GTK Official Site\">GTK<\/a>. It&#8217;s popular to the point of ubiquity and is available on both Linux and Windows. Anything I write that uses GTK ought to be able to compile on either platform. <\/p>\n<p>When I want to use some code, the Windows tradition is to go to the website, download it, and then <a href=\"?p=9557\" title=\"Object-Disoriented Programming\">cuss at the install scripts in outraged bafflement<\/a> until you give up and try something else. I assume that&#8217;s also how we do things here on Linux?  I download GTK from the website and begin squinting at the .\/configure scripts, trying to figure out how they should work, why they aren&#8217;t working now, and what I need to do to get them from here to there. GTK depends on no less than five other projects, although none of those projects seems to depend on anything. So our dependencies are broad but shallow. This is better than narrow but deep, but not nearly as good as &#8220;no dependencies&#8221;, which never happens because LOL GET A REAL PROGRAMING LANGUAG YOU FOSIL.<\/p>\n<p>Sigh.<\/p>\n<p>After about 45 minutes of frustration I haven&#8217;t made any headway. Even if I get this configuration script to work, I don&#8217;t understand where I&#8217;m supposed to put these files or how to tell the IDE where to find them. This is because there are only two types of programming tutorials on the net:<\/p>\n<ol>\n<li>Buttons are useful! Here is how to identify a button, and how to use your finger to press one!\n<\/li>\n<li>Here is how to deal with a flame-out in an F\/A-18 Hornet while on approach to a Nimitz class carrier. This tutorial is particularly focused on daytime scenarios. If this happens in nighttime fly conditions or you&#8217;re operating in sub-tropical weather, please consult a more appropriate guide.\n<\/li>\n<\/ol>\n<p>There is no bridge between baby steps and ninjutsu. This problem is particularly bad in the C\/C++ world where every development environment seems to have a slightly different (or radically different) solution, so it&#8217;s not possible for someone to write a sensible, general-purpose guide. <\/p>\n<p>Eventually I discover that this business of downloading and configuring stuff manually is only for obscure packages or hardcore devs with exotic requirements. For most people, you can get stuff like this from the Software Manager. It works a bit like Windows Update, except it downloads all kinds of different software, themes, updates, tools, packages, and other nuggets of digital treasure. You can also do this using the terminal, which is how I discovered this feature, but sense I could really make a mess doing things that way.  In one forum I find the example terminal command:<\/p>\n<p><tt>sudo apt-get install gtk2.0+-<\/tt><\/p>\n<p>Breaking this down for the curious:<\/p>\n<p><tt>sudo<\/tt> stands for &#8220;<strong>S<\/strong>uper <strong>U<\/strong>ser <strong>DO<\/strong>&#8220;.  It means you want to execute this command with root privileges, which are required for installing new stuff.<\/p>\n<p><tt>apt-get<\/tt> Stands for <strong>A<\/strong>dvanced <strong>P<\/strong>ackaging <strong>T<\/strong>ool <strong>get<\/strong>. The apt is used for downloading and installing new components, making sure they end up in the right places, and making sure the system knows where they are. Here you&#8217;re telling the apt to get something.<\/p>\n<p><tt>install<\/tt> means you want to install this thing. I&#8217;m sure this is obvious to you but explaining it allows me to feel superior and smart even though I have no idea what I&#8217;m doing.<\/p>\n<p><tt>gtk2.0+-<\/tt> means it should download the GTK package, version 2.0.  I don&#8217;t know what the plus-minus stands for on the end. <\/p>\n<p>The problem here is that GTK is now on version 3.6. Do I have it on my system already? Which version? If not, which version is best to get? Will any particular version cause conflicts with things I already have installed? (It shouldn&#8217;t, of course. We&#8217;re downloading source files, not executables. Still, I don&#8217;t know how this install might impact Eclipse or code::blocks, which might be changed, or what else might go wrong. In programming, <em>what you don&#8217;t know can actually hurt you and is very likely to do so<\/em>.<\/p>\n<p><table width='600'  cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/linux_software_manager.jpg' class='insetimage' width='600' alt='Software Manager for Linux Mint' title='Software Manager for Linux Mint'\/><\/td><\/tr><\/table><\/p>\n<p>So I fire up the software manager and try to figure out if I have GTK, what version I have, and if I don&#8217;t have it, how to get it. This is very, very hard because GTK is used by a lot of programs. For example, the interface of <a href=\"http:\/\/www.gimp.org\/\" title=\"GNU Image Manipulation Program\">GIMP<\/a> is built on GTK. (Photoshop for Open Source hippies.) So in the software manager, the description is something like &#8220;GIMP using GTK library&#8221; or whatever. When I search for GTK packages, I get hundreds of results, wading through them takes forever, and I&#8217;m not even sure if I&#8217;m on the right track.<\/p>\n<p>It&#8217;s like if you want to bake something with chocolate, so you do a search for just &#8220;chocolate&#8221;.  The search results are clogged with chocolate cookies, chocolate cake, chocolate bar, chocolate frosting, chocolate chips, chocolate milk, chocolate Santas, chocolate bunnies, chocolate sprinkles, chocolate ice cream, chocolate mint, chocolate-covered *&#8217;s, chocolate flavor, chocolate color, chocolate-scented candles, chocolate cereal, chocolate syrup, chocolate substitutes, chocolate addiction, chocolate gifts, artificial chocolate flavoring, chocolate powder, removing chocolate stains, bulk chocolate, diet chocolate, kosher chocolate, vegan chocolate, lactose-free chocolate, gluten-free chocolate, and taxes on chocolate.<\/p>\n<p><em>What about chocolate bars? Is that what you need? It kind of looks like it. Maybe you&#8217;re supposed to melt it down. But it&#8217;s got sugar in it, and your recipe calls for sugar. Hmmm.<\/em><\/p>\n<p>Of course, the phrase you&#8217;re looking for is &#8220;BAKING CHOCOLATE&#8221;. If you know this then the search is stupid easy and if you don&#8217;t then the search is impossible. In my case, the phrase I was looking for is &#8220;libgtk&#8221;. It turns out that terminal command above was incorrect. (Or old. Or both.) By narrowing my search to libgtk I&#8217;m able to find the components for building GTK applications. There are many, and I seem to have everything except the core files. The version available in software manager is 3.0 and the latest is 3.6, but I&#8217;m betting (hoping!) that the 3.0 version is just fine and was chosen because it was the version with the least potential conflicts.<\/p>\n<p>So I install it. <\/p>\n<p>Now what?<\/p>\n<p>I try #including &lt;gtk.h&gt; in both Eclipse and code::blocks, which naturally doesn&#8217;t work. Do I need to make it &lt;gtk\/gtk.h&gt;? Or perhaps &lt;gtk3-0\/gtk\/gtk.h&gt;? Or maybe &lt;gtk3-0\/gtk.h&gt;? I find examples and variants of all of these in searches, none of them work, and I have no idea how to do this amazingly simple, straightforward thing. I don&#8217;t know where these files are on my computer, how to find them, or how to tell my IDE how to find them. (I search file system for gtk.h, and a long search turns up bupkis.) <\/p>\n<p>This is pretty demoralizing. In the time I&#8217;ve sunk into this so far I could have installed Windows 7 and Visual Studio and just returned to work. I wouldn&#8217;t mind if I felt like I was making progress, but I really didn&#8217;t expect to spend two and a half hours trying to write my first line of code. The problem with situations like this is that you don&#8217;t know how deep the rabbit hole goes. I could solve this problem thirty seconds from now. Or maybe it will take another hour. Maybe when I solve this problem there will be another one that will require a similar investment of time. Maybe I&#8217;ll get stuck on a new compile problem. Or a linker problem. Or an execution problem. There&#8217;s no limit to how many things can go wrong or how long it can take to fix each one. <\/p>\n<p>It&#8217;s entirely possible I&#8217;ll slam away at this problem, fix it, and run into another problem that&#8217;s baffling and insurmountable. Even if you&#8217;ve got a good friend who is really patient and knows all about this sort of thing, answers to these sorts of questions often begin with, &#8220;Well, depending on your setup&#8230;&#8221;<\/p>\n<p>It&#8217;s like a game of chance where you keep betting time, and if you win all you get is the chance to make another wager. How much time do you put in before you conclude this isn&#8217;t going to pay off?<\/p>\n<p>I&#8217;m going to go play Minecraft until I get enough patience to continue. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>If I&#8217;m going to indulge this pipe-dream of Linux-using, then it&#8217;s time to stop fussing around in Minecraft and work on something serious. It&#8217;s time to see if I can use Linux to program. If I can&#8217;t do that, then I ought to walk away now before I get too comfortable. Going by the comments [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[273],"class_list":["post-18128","post","type-post","status-publish","format-standard","hentry","category-personal","tag-linux"],"_links":{"self":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts\/18128","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=18128"}],"version-history":[{"count":0,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts\/18128\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=18128"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=18128"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=18128"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}