{"id":11804,"date":"2015-03-25T23:12:22","date_gmt":"2015-03-26T03:12:22","guid":{"rendered":"http:\/\/scruss.com\/blog\/?p=11804"},"modified":"2018-09-26T14:59:31","modified_gmt":"2018-09-26T18:59:31","slug":"running-freebasic-on-raspberry-pi","status":"publish","type":"post","link":"https:\/\/scruss.com\/blog\/2015\/03\/25\/running-freebasic-on-raspberry-pi\/","title":{"rendered":"Running FreeBASIC on Raspberry Pi"},"content":{"rendered":"<p><span style=\"color: #ff0000;\"><em><strong>Hey! <\/strong>This is yet another of my ancient posts about Raspberry Pis that probably contains out-of-date information. In order to run FreeBASIC on a Raspberry Pi, all you need do is:<\/em><\/span><\/p>\n<ol>\n<li><span style=\"color: #ff0000;\"><em>Download a <a style=\"color: #ff0000;\" href=\"http:\/\/users.freebasic-portal.de\/stw\/builds\/linux-armv6-rpi\/\">nightly build<\/a><\/em><\/span><\/li>\n<li><span style=\"color: #ff0000;\"><em>Unpack it and run the installer.<\/em><\/span><\/li>\n<\/ol>\n<p><span style=\"color: #ff0000;\"><em>That&#8217;s it! You can access GPIO with FreeBASIC, too: <\/em><a style=\"color: #ff0000;\" href=\"https:\/\/github.com\/scruss\/FreeBASIC_Blink\"><span class=\"flex-auto mb-2\"><span class=\"text-gray-dark mr-2\"><em>GPIO LED Blink using FreeBASIC and WiringPi<\/em> <\/span><\/span><\/a><\/span><\/p>\n<p><a href=\"http:\/\/freebasic.net\/\">FreeBASIC<\/a> is a pretty nifty cross-platform BASIC compiler. It uses a Microsoft-like syntax, has an <a href=\"http:\/\/www.freebasic.net\/forum\/\">active user and developer base<\/a>, and is quite fast. Building the latest version on a Raspberry Pi is a bit of a challenge, though.<\/p>\n<figure id=\"attachment_11805\" aria-describedby=\"caption-attachment-11805\" style=\"width: 320px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2015\/03\/2015-03-25-220608_freebasic_pi.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-11805\" src=\"http:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2015\/03\/2015-03-25-220608_freebasic_pi-320x226.png\" alt=\"FreeBASIC 1.01 demo running on a Raspberry Pi\" width=\"320\" height=\"226\" srcset=\"https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2015\/03\/2015-03-25-220608_freebasic_pi-320x226.png 320w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2015\/03\/2015-03-25-220608_freebasic_pi-160x113.png 160w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2015\/03\/2015-03-25-220608_freebasic_pi.png 902w\" sizes=\"auto, (max-width: 320px) 100vw, 320px\" \/><\/a><figcaption id=\"caption-attachment-11805\" class=\"wp-caption-text\">FreeBASIC 1.01 demo running on a Raspberry Pi from Geany<\/figcaption><\/figure>\n<p>Part of the problem is that FreeBASIC is mostly written in FreeBASIC, so you need a working compiler to bootstrap the latest version.<\/p>\n<p><strong><span style=\"color: #ff0000;\">Update<\/span><\/strong><span style=\"color: #000000;\">: you&#8217;re probably best just downloading the binary install packages from the FreeBASIC site. I&#8217;m having difficulty getting recent (late 2016) source packages to build for reasons that would take too long for most people to care about.<\/span><\/p>\n<p>The following steps worked for me:<\/p>\n<ol>\n<li>Install some necessary packages:\n<pre>sudo apt-get install build-essential libncurses5-dev libffi-dev libgl1-mesa-dev libx11-dev libxext-dev libxrender-dev libxrandr-dev libxpm-dev ncurses-doc libxcb-doc libxext-doc libgpm-dev git libcunit1 libcunit1-dev libcunit1-doc<\/pre>\n<p>(You don&#8217;t really have to include the <em>cunit<\/em> packages; they&#8217;re only needed if you run tests before installation.)<\/li>\n<li>Download a nightly binary from Sebastian&#8217;s server: <a href=\"http:\/\/users.freebasic-portal.de\/stw\/builds\/linux-armv6-rpi\/\">http:\/\/users.freebasic-portal.de\/stw\/builds\/linux-armv6-rpi\/<\/a>\u00c2\u00a0 and install it:\n<pre>unzip fbc_linux_armv6_rpi_<em>version<\/em>.zip\r\ncd fbc_linux_armv6_rpi\/\r\nchmod +x install.sh\r\nsudo .\/install.sh -i<\/pre>\n<p>Don&#8217;t delete the installation folder just yet.<\/li>\n<li>Grab the latest version of the source from github:\n<pre>cd\r\ngit clone https:\/\/github.com\/freebasic\/fbc.git<\/pre>\n<p>Change directory to the new FreeBASIC source folder (<tt>cd fbc<\/tt>), and type <tt>make<\/tt>. (or, on a Raspberry Pi 2 or 3, <tt>make -j4<\/tt> to use\u00c2\u00a0<em>all<\/em> the cores \u00e2\u20ac\u00a6). After a while (in my tests, about 52 minutes on a 512 MB Raspberry Pi, or around 6\u00c2\u00bd minutes [<em>!<\/em>] on a Raspberry Pi 2), it should finish. If there&#8217;s a <tt>bin\/fbc<\/tt> file, the compilation worked!<\/li>\n<li>Before you install the new compiler, uninstall the old one: change directory to the <tt>fbc_linux_armv6_rpi<\/tt> folder, and type:\n<pre>sudo .\/install.sh -u<\/pre>\n<\/li>\n<li>Once that&#8217;s done, go back to the new <tt>fbc<\/tt> folder, and type:\n<pre>sudo make install<\/pre>\n<\/li>\n<\/ol>\n<p>And you&#8217;re done! You can delete the <tt>fbc_linux_armv6_rpi<\/tt> folder now. If you don&#8217;t mind it taking up space, keep the <tt>fbc<\/tt> folder to allow you a quick rebuild of the latest version of the compiler with:<\/p>\n<pre>cd fbc\r\ngit pull\r\nmake\r\nsudo make install<\/pre>\n<p>Note that this will build a native <em>armv7l<\/em> compiler on a Raspberry Pi 2, and an <em>armv6l<\/em> one on a Raspberry Pi. This means you can&#8217;t run binaries you built on a Raspberry Pi 2 on a Raspberry Pi (you&#8217;ll get an <tt>Illegal Instruction<\/tt> error), but you should be able to run ones built on a Raspberry Pi on a Raspberry Pi 2. Binary compatibility is overrated, anyway \u00e2\u20ac\u00a6<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hey! This is yet another of my ancient posts about Raspberry Pis that probably contains out-of-date information. In order to run FreeBASIC on a Raspberry Pi, all you need do is: Download a nightly build Unpack it and run the installer. That&#8217;s it! You can access GPIO with FreeBASIC, too: GPIO LED Blink using FreeBASIC [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[7],"tags":[2062,2872,2873,2510],"class_list":["post-11804","post","type-post","status-publish","format-standard","hentry","category-computers-suck","tag-basic","tag-freebasic","tag-quickbasic","tag-raspberrypi"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pQNZZ-34o","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts\/11804","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/comments?post=11804"}],"version-history":[{"count":5,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts\/11804\/revisions"}],"predecessor-version":[{"id":15177,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts\/11804\/revisions\/15177"}],"wp:attachment":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/media?parent=11804"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/categories?post=11804"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/tags?post=11804"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}