Using MS Windows to develop for Raspberry Pi

Building Raspberry Pi Applications on Windows.

So you’ve got a Raspberry Pi (Rasp for short) and would like to build applications. The best tools are available for Linux, Debian or Ubuntu. But you are a (MS) Windows programmer and would like to generate code for Raspberry Pi on a Windows machine. If you are looking for C++ compiler then you have two options.

They both generate 32-bit code. To use Ian Lindsell’s tools you need to install 32-bit Cygwin. System GCC comes with ‘batteries included.’ But then if you want to compile Forran code you are out of luck. I landed up installing gfortran on Raspberry. From raspbian:advanced:gfortran setup:

TO INSTALL gfortran, from the pi user command prompt

  • remember to update : sudo apt-get update
  • Install gfortran: sudo apt-get install gfortran
  • Install gfortran-doc (if desired): sudo apt-get install gfortran-doc

If you are not familiar with gfortran you should install Cygwin and build/test Fortran applications from the cygwin command line prompt.

The next question is how do you connect Rasp to the internet (assuming you are doing it at home). If you can run a wire between your modem and Rasp then all you have to do is enable dhcp and you are home. But in my case as in many homes I am sure, you will be connected to the internet via WiFi. In than case you need to connect Rasp to you Windows using RJ45 the ethernet cable. Either connect it via a cross over cable. Network switches are pretty cheap these days. If you have a free powersocket then a switch will do as well.

Assuming you have connected a monitor and keyboard to Rasp, login to Rasp, and run

sudo vi /etc/network/interface

You now have to change the eth0 settings as follows

iface etho inet static
address 192.168.137.2
netmask 255.255.255.0
network 192.168.137.0
broadcast 192.168.137.255
gateway 192.168.137.1

I have changed the eth0 from dhcp to static. Hence I have to specify the address in full detail. In my case the address of Rasp is 192.168.137.2 and the IP address of my PC on the ethernet port is 192.168.137.1. The other details configure the mask. Notice that 254 addresses are consumed because of the 255.255.255.0 mask.
Modify /etc/resolv.conf to your gateway, eg.:
nameserver 192.168.0.1
The original nameserver was 8.8.8.8

On the Windows machine open network connections. Modify the ethernet address to a static value of, in my case,192.168.137.1. Launch (by right clicking and selecting properties) the wifi network properties and tick “sharing/Internet Connection/Allow other network users to connect to the internet through this computer”

Reboot Rasp and verify that you can ping google.com. If so Rasp has just been connected to the World Wide Web. You now have access to a whole lot of tools of applications through apt-get.

Advertisements

About The Sunday Programmer

Joe is an experienced C++/C# developer on Windows. Currently looking out for an opening in C/C++ on Windows or Linux.
This entry was posted in Software Engineering and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s