{"id":150,"date":"2012-10-09T15:15:46","date_gmt":"2012-10-09T15:15:46","guid":{"rendered":"https:\/\/raspberry-projects.com\/pi\/?p=150"},"modified":"2015-05-28T10:11:25","modified_gmt":"2015-05-28T10:11:25","slug":"programming-the-rpi-in-windows-using-eclipse","status":"publish","type":"post","link":"https:\/\/raspberry-projects.com\/pi\/programming-in-c\/compilers-and-ides\/eclipse\/programming-the-rpi-in-windows-using-eclipse","title":{"rendered":".Setting Up Windows Eclipse Programming of the RPi"},"content":{"rendered":"<p>\n<strong><em><span style=\"color:#FF0000;\">We no longer use this approach and this page may be out of date &#8211; it is left here for archive puropses. &nbsp;We now use NetBeans&nbsp;for C\/C++ development on the RPi, see <\/span><u><a href=\"https:\/\/raspberry-projects.com\/pi\/programming-in-c\/compilers-and-ides\/netbeans-windows\/installing-netbeans-for-c-remote-development-on-a-raspberry-pi\"><span style=\"color:#FF0000;\">here<\/span><\/a><\/u><span style=\"color:#FF0000;\">.<\/span><\/em><\/strong>\n<\/p>\n<p>\nUsing A Windows PC to develop C code for your Raspberry Pi can be done.\n<\/p>\n<p>\nThese notes on how to do it below are based very much on <a href=\"http:\/\/www.a2p.it\/wordpress\/tech-stuff\/development\/remote-debugging-raspberrypi\/\" target=\"blank\"> Alessio Placitelli&#39;s great guide<\/a> which details the steps required and you may wish to follow his original guide instead.\n<\/p>\n<p>\nNote that Eclipse is not for the faint hearted! It is a very powerful but very complex programming IDE which can easily confuse the hell out of you and have you banging your head against a wall for hours if it doesn&#39;t just work, often because something has changed requiring some new set-up step to make things work as before or work the same on your system compared to the system of someone who has created a set-up guide (just like this one!). The be fair to Eclipse, this isn&#39;t so much it being a bad program (actually once setup right its fantastic to use), but more that it is designed to be used in a wide range of situations rather than being a manufacturer produced self configuring software package for a single specific use like many other programming IDE&#39;s. &nbsp;If you are new to C programming by all means give this set-up a go, but if it doesn&#39;t work out it isn&#39;t just you &#8211; loads of perfectly competent programmers have problems understanding Eclipse and the tools it connects with well enough to make it work right for them! Following our <a href=\"https:\/\/raspberry-projects.com\/pi\/programming-in-c\/getting-your-raspberry-pi-ready-for-c-programming\" target=\"_blank\">Geany based guide<\/a> is a much easier and simpler way to get up and running with programming in C on the Raspberry Pi if Eclipse defeats you for now.\n<\/p>\n<p>\nOne other word of warning &#8211;&nbsp;this solution uses a cross compiler, which is how you are able to compile on an Intel platform for the ARM based Raspberry Pi. &nbsp;This is fine if you are using the standard C libraries and maybe one or two additional libraries you can manually copy over such as&nbsp;the RPI IO pin library, SQL server library. &nbsp;However its a major problem if you want to use libraries with a large number of dependent libraries, for instance programming GTK+ applications, as the libraries are not part of the cross compiler and you need to get pretty advanced dealing with how to copy them over so eclipse can reference them. &nbsp;At this point its a bit easier if you are using eclipse on a Linux OS but its still a major problem as Linux on a PC will be running on Intel not ARM so the libraries are different. If you want to do programming like this &nbsp;you will either need to find a way of getting the library files passed to eclipse from the RPi or instead work on the RPi itself and accept its hardware limitations (the fact that the compiler just works with all its installed libraries vs being slower to use than a general PC).\n<\/p>\n<p>\nThat all said, getting eclipse working as described below is very cool and very productive, but best to be informed up front rather than finding out&nbsp;the hard way!\n<\/p>\n<h4>\nSetting Up Your Windows PC<br \/>\n<\/h4>\n<h5>\nSetup Cygwin on your machine<br \/>\n<\/h5>\n<p>\nCygwin gives your Windows machine the Linux functionality needed.\n<\/p>\n<p>\nDownload the setup.exe file from <a href=\"http:\/\/cygwin.com\/setup.exe\" target=\"_blank\">here<\/a> and store it in a folder called &quot;c:\\cygwin&quot;\n<\/p>\n<p>\nRun it (right click and select Run as administrator &#8211; we&#39;re not sure this is needed, but we ran into problems with our first installation and tried this on a subsequent successful installation which worked)\n<\/p>\n<p>\nAt the &#39;Select Packages&#39; page ensure the following are set to install:\n<\/p>\n<ul>\n<li>\nPython &gt;python: Python langauge interpreter\n<\/li>\n<li>\nShells &gt; bash: The GNU&nbsp;Burne&nbsp;Again&nbsp;SHell\n<\/li>\n<li>\nShells &gt;&nbsp;mintty: Terminal emulator with native Windows look and feel\n<\/li>\n<li>\nDevel &gt; make: The GNU version of the &#39;make&#39; utility\n<\/li>\n<li>\nDevel &gt; binutils: The GNU assembler, linker and binary utilities\n<\/li>\n<li>\nDevel&nbsp;&#8211; entire folder (we&#39;re not sure this is actually needed, but we ran into problems with our first installation and tried this on a&nbsp;successful subsequent installation instead of just make and binutils to ensure everything was present).\n<\/li>\n<li>\nDebug&nbsp;&#8211; entire folder (we&#39;re not sure this is actually needed but added it on our installation just in case &#8211; however if you are short on disk space leave it out ande see how you go as it adds a few GB of files.).\n<\/li>\n<\/ul>\n<h5>\nInstall the cross-compilation toolchain<br \/>\n<\/h5>\n<p>\nThis allows us to use windows but to compile and debug software which runs on the Raspberry Pi ARM.\n<\/p>\n<p>\nDownload the hardfp version (arm-unknown-linux-gnueabi-hardfp-gdbV1.zip) of the toolchain kindly shared by IanLinsdell, available from his <a href=\"https:\/\/github.com\/IanLinsdell\/Raspberrypi\" target=\"_blank\">github account<\/a>. Note that if you don&#39;t have git software click the ZIP download button to get the files.\n<\/p>\n<p>\nUnzip it into C:\/cygwin\/opt\/cross\/x-tools so that the full path is like this C:\/cygwin\/opt\/cross\/x-tools\/arm-unknown-linux-gnueabi.\n<\/p>\n<p>\nNote that this must extract without errors &#8211; if you get a filename too long message extract it to a directory straight off C:\\ and move it afterwards\n<\/p>\n<h5>\nInstall PuTTY<br \/>\n<\/h5>\n<p>\nPuTTY is used to communicate with the Raspberry Pi using SSH.\n<\/p>\n<p>\nDownload the windows installer for PuTTY <a href=\"http:\/\/www.chiark.greenend.org.uk\/~sgtatham\/putty\/\" target=\"_blank\">from here<\/a>.\n<\/p>\n<p>\nUse <a href=\"http:\/\/www.a2p.it\/wordpress\/tech-stuff\/development\/remote-debugging-raspberrypi\/\" target=\"_blank\">Alessio Placitelli&#39;s<\/a> nifty little hack to create a script which run as a post-build step in Eclipse to upload the file to the board using SSH and executes a few commands.\n<\/p>\n<p>\nSave the following as &quot;C:\\eclipse\\deployment_scripts\\rpi_deploy_debug.bat&quot;\n<\/p>\n<pre>\r\n<code>\r\n@echo off\r\n \r\nrem Check for a valid filename\r\nIF &quot;%1&quot;==&quot;&quot; (\r\n    ECHO You have to provide a valid source file.\r\n    EXIT \/b\r\n)\r\n \r\nIF &quot;%2&quot;==&quot;&quot; (\r\n    ECHO You have to provide a valid destination path.\r\n    EXIT \/b\r\n)\r\n \r\nSET PUTTYSCP_BIN=&quot;C:\\Program Files (x86)\\PuTTY\\pscp.exe&quot;\r\nSET PUTTY_BIN=&quot;C:\\Program Files (x86)\\PuTTY\\putty.exe&quot;\r\nSET RASPBERRYPI_ADDR=192.168.0.123\r\nSET USERNAME=pi\r\nSET PASSWORD=raspberry\r\nSET CMD_FILENAME=commands.sh\r\n \r\nrem Upload the file to raspberry pi\r\n%PUTTYSCP_BIN% -pw %PASSWORD% &quot;%1&quot; %USERNAME%@%RASPBERRYPI_ADDR%:&quot;%2&quot;\r\n \r\nrem Build a list of actions to do on the pi (chmod, execute GDB server)\r\nif exist %~dp0%CMD_FILENAME% del %~dp0%CMD_FILENAME%\r\nrem echo rm &quot;%2&quot; &gt;&gt; %~dp0%CMD_FILENAME%\r\necho chmod +x &quot;%2&quot; &gt;&gt; %~dp0%CMD_FILENAME%\r\necho gdbserver :3785 &quot;%2&quot; &gt;&gt; %~dp0%CMD_FILENAME%\r\n \r\nrem Execute the action list on the raspberry pi\r\n%PUTTY_BIN% -pw %PASSWORD% -m %~dp0%CMD_FILENAME% %USERNAME%@%RASPBERRYPI_ADDR%\r\n \r\nexit \/b %ERRORLEVEL%\r\n<\/code><\/pre>\n<p>\nEdit the file as follows:\n<\/p>\n<ul>\n<li>\nPUTTYSCP_BIN &ndash; The full path to pscp.exe, part of the Putty bundle, used to securely copy files over a SSH connection.\n<\/li>\n<li>\nPUTTY_BIN &ndash; The full path to putty.exe, part of the Putty bundle, used to execute commands on a remote host over a SSH connection.\n<\/li>\n<li>\nRASPBERRYPI_ADDR &ndash; The IP address of the Raspberry Pi\n<\/li>\n<li>\nUSERNAME &ndash; The username of the user who will authenticate on the Raspberry Pi\n<\/li>\n<li>\nPASSWORD &ndash; The password\n<\/li>\n<li>\nCMD_FILENAME &ndash; The name of the file which will contains all the commands to be executed on the Raspberry Pi (don&rsquo; change, it&rsquo;s not really needded)\n<\/li>\n<\/ul>\n<h5>\nInstall Eclipse IDE for C\/C++ Developers<br \/>\n<\/h5>\n<p>\nDownload Eclipse IDE for C\/C++ Developers (CDT) <a href=\"http:\/\/www.eclipse.org\/downloads\/\" target=\"_blank\">from here<\/a>.\n<\/p>\n<p>\nStore it in a folder, for instance &quot;c:\\eclipse\\eclipse_v#_#&quot;\n<\/p>\n<p>\n<br \/>\nIf you don&#39;t have it you also need to install the java runtuime environment (see the readme folder)\n<\/p>\n<p>\nRun eclipse by running the eclipse.exe in the folder.\n<\/p>\n<h4>\nSetup On The Raspberry Pi<br \/>\n<\/h4>\n<h5>\nEnable The Raspberry Pi SSH Server<br \/>\n<\/h5>\n<p>\nThe RPi needs to be running a SSH server so we can upload the binaries we compile to it. If you are using the Raspbian OS run this at the command prompt and turn the SSH Server on:\n<\/p>\n<pre>\r\n<code>sudo raspi-config<\/code><\/pre>\n<p>\nWith the SSH server running you can access the Raspberry Pi command line from your Windows machine using a SSH terminal.\n<\/p>\n<h5>\nRaspberry Pi IP Address<br \/>\n<\/h5>\n<p>\nTo see your Raspberry Pi IP address type:\n<\/p>\n<pre>\r\n<code>ifconfig<\/code><\/pre>\n<p>\nIf your Raspberry Pi has a new IP address see <a href=\"https:\/\/raspberry-projects.com\/pi\/programming-in-c\/compilers-and-ides\/eclipse\/updating-eclipse-project-settings\">here<\/a>.\n<\/p>\n<h4>\nOther Solutions<br \/>\n<\/h4>\n<p>\n<a href=\"http:\/\/www.gurucoding.com\/en\/raspberry_pi_eclipse\/installing_eclipse.php\" target=\"_blank\">gurucoding.com<\/a>\n<\/p>\n<h4>\nCross Compiling Tools<br \/>\n<\/h4>\n<p>\nCross compiling applications which use external libraries needs all of the necessary libraries to have been&nbsp;cross-compiled from source so they can be included in the build process. Many larger libraries (e.g.&nbsp;GTK+) also depend on other libraries that must also have been&nbsp;cross compiled. This isn&#39;t a problem when compiling on the RPi&nbsp;as it can just get the&nbsp;libraries using apt-get all ready to use on its ARM architecture, or get them and then compile them on its own target platform. &nbsp;But if you are using eclipse on a windows or&nbsp;linux PC, the libraries won&#39;t be the same as even your linux PC will be&nbsp;Intel not ARM. &nbsp;The solution here is to either resort to compiling on the RPi&nbsp;which defeats the purpose of having moved development off it to a faster platform,&nbsp;having to cross compile each required library and all if its dependencies manually, or finding a way to just copy the necessary library files over from the RPi.\n<\/p>\n<p>\nSome tools which are designed to help with cross compiling large projects with external libraries:\n<\/p>\n<p style=\"margin-left: 40px;\">\n<a href=\"http:\/\/www.scratchbox.org\/\" target=\"_blank\">Scratchbox<\/a><br \/>\n<a href=\"https:\/\/maemo.gitorious.org\/scratchbox2\/pages\/Home\" target=\"_blank\">Scratchbox2<\/a><br \/>\n<a href=\"http:\/\/buildroot.uclibc.org\/\" target=\"_blank\">Buildroot<\/a>\n<\/p>\n<p>\nFor info on copying the necessary library files over see <a href=\"https:\/\/raspberry-projects.com\/pi\/programming-in-c\/compilers-and-ides\/eclipse\/adding-libraries-to-eclipse-for-windows\">here<\/a>.\n<\/p>\n<p>\n&nbsp;\n<\/p>\n<p>\n&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We no longer use this approach and this page may be out of date &#8211; it is left here for archive puropses. &nbsp;We now use NetBeans&nbsp;for C\/C++ development on the RPi, see here. Using A Windows PC to develop C code for your Raspberry Pi can be done. These notes on how to do it [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[],"class_list":["post-150","post","type-post","status-publish","format-standard","hentry","category-eclipse"],"_links":{"self":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts\/150","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/comments?post=150"}],"version-history":[{"count":110,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts\/150\/revisions"}],"predecessor-version":[{"id":1959,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts\/150\/revisions\/1959"}],"wp:attachment":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/media?parent=150"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/categories?post=150"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/tags?post=150"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}