bobbymg
Posts: 20
Joined: Tue Mar 12, 2019 11:48 pm

New to Raspberry, old to programming

Wed Mar 13, 2019 3:46 pm

I'm a retired embedded micro programmer, 10yrs of assembly and 10yrs of C. I haven't touched a line of code since I retired 10 yrs ago. I feel it's time to refresh my skills before I've forgotten everything. I just bought a Raspberry Pi 3+. What an impressive little box. Looks like it can do most everything a PC can do. What I want to do is develop C code on my Windows XP machine to run on the Raspberry. Is there a cross compiler available to do this? What will I need?

Bob D.

User avatar
RogerW
Posts: 285
Joined: Sat Dec 20, 2014 12:15 pm
Location: London UK

Re: New to Raspberry, old to programming

Wed Mar 13, 2019 4:40 pm

Like you I retired a while ago (17 years). I have mainly used python on the pi but recently gone back to C++ for a robot project. I would suggest you don't discount doing all the development on the pi.
I have a B+ so not the fastest and have found it to be practical. I use codeblocks which is a basic but quite workable ide and the edit/compile/run process is fine for a relatively small program.

jahboater
Posts: 4690
Joined: Wed Feb 04, 2015 6:38 pm

Re: New to Raspberry, old to programming

Wed Mar 13, 2019 4:48 pm

RogerW wrote:
Wed Mar 13, 2019 4:40 pm
I would suggest you don't discount doing all the development on the pi.
+1
IMO the compiler, debugger, editors, and other software tools included within Raspbian are first class and can easily cope with very large projects.

Heater
Posts: 13357
Joined: Tue Jul 17, 2012 3:02 pm

Re: New to Raspberry, old to programming

Wed Mar 13, 2019 5:00 pm

I second or third all of the above.

The Raspi runs a full up Linux distribution, think Unix, and has everything you need to program in assembler, C or many other languages.

Life will be much easier if you skip the complication of trying to cross compile code on a PC.
Memory in C++ is a leaky abstraction .

swampdog
Posts: 239
Joined: Fri Dec 04, 2015 11:22 am

Re: New to Raspberry, old to programming

Wed Mar 13, 2019 9:12 pm

It would be more trouble than it's worth trying to do anything from WinXP with it being out of support. Like the others have suggested, you can develop quite easily on the rpi directly. You can certainly use your XP machine for the display etc (hint: VNC/putty) ... though before you dive into that it may be worthwhile grabbing a "live cd" of linux Mint (pick "mate" because its graphical overhead is less than "cinamon") and try that on your PC. The live cd won't touch XP unless you hit the "install" icon on the desktop. Also try the Ubuntu live cd. Same thing but I'm not familiar with desktop ubuntu. Both are based on "debian" (as is raspian) so most of what you learn will be in common. There's arm cross-compilers for debian.

Once you've figured out which will work best you can use a tool (eg: a "gparted" live cd) to shrink some XP space in order to fit one of those distros on your PC and dual boot. You'll then be able to display the raspian desktop on your PC (if you want) or just use the PC linux command line to 'ssh' into the rpi.

There's new features in 'gcc' but it'll still compile 10 year old code. The rpi can be sluggish compiling C++ but you'd have to really go nuts to make the hassle of cross-compiling C on a PC worthwhile.

User avatar
AdamStanislav
Posts: 147
Joined: Sun Mar 10, 2019 2:44 am
Location: Wisconsin
Contact: YouTube

Re: New to Raspberry, old to programming

Thu Mar 14, 2019 1:35 am

I can relate to you. I am retired and disabled, and I have always enjoyed programming in assembly language (and now with the RPi I have to learned a completely different assembly language :lol: ) and in C (at least that is mostly the same). I am quite impressed by the RPi, as it is faster and has more memory and better video than the original desktop personal computers.

Brian Beuken
Posts: 177
Joined: Fri Jan 29, 2016 12:51 pm

Re: New to Raspberry, old to programming

Thu Mar 14, 2019 8:57 am

I was going to chip in with my usual, use Visual Studio C++ for Linux, or Visual Studio with visualGDB plug in for almost painless compiling on your PC to your RPi. then I saw Windows XP...and I decided best not..

Is there no way you can upgrade to Wndows 8 or 10? It opens up a whole new world of tools and sytems that make coding the pi simplicity itself?
Very old computer game programmer, now teaching very young computer game programmers, some very bad habits.
Wrote some book about coding Pi's and SBC's, it's out now...go get it!
http://www.scratchpadgames.net/

dsyleixa123
Posts: 405
Joined: Mon Jun 11, 2018 11:22 am

Re: New to Raspberry, old to programming

Thu Mar 14, 2019 9:19 am

I double that.
Plug keyboard, mouse (preferably WL), WiFi stick, and a full-HD HDMI screen (for development preferably >=20", optionally replaceable by HDMI touch screens >=7") to your Pi and start programming locally, never ever cross-compiling!
https://www.raspberrypi.org/magpi/issue ... ials-c-v1/

Brian Beuken
Posts: 177
Joined: Fri Jan 29, 2016 12:51 pm

Re: New to Raspberry, old to programming

Thu Mar 14, 2019 6:51 pm

There's a very worrying trend in these discussions about finding the hardest way to do a simple thing.

As a professional games developer and teacher in games programming, I'm utterly gobsmacked that people are advocating working on the Pi as a 1st choice.. No, hell no, cross platform dev, be that using a cross compilier or an editor/debugger with on target compiles are 100 times better, faster and easier to work with.

Working on the Pi when thats all you've got is viable and I'm happy to do that sometimes, but its by no means the best solution,especially if you need graphic output on your project, you need screen space to view your project and the debuggers and profilers, you need the files and asets to be secure in the case of a catastrophic crash bug, you need your memory maximised, you need to be able to turn your builds around in record time.

Cross compiling can be a little tricky to set up, but once done it is far and away the best way to work, using the speed of your PC, keeping the Pi's storage clean, keeping the Pi's memory as bare as possible and letting it focus its resources on your running project.

There's no prizes for doing a simple thing the hard way...use the right tools and enjoy the simplicity of coding.
Very old computer game programmer, now teaching very young computer game programmers, some very bad habits.
Wrote some book about coding Pi's and SBC's, it's out now...go get it!
http://www.scratchpadgames.net/

jahboater
Posts: 4690
Joined: Wed Feb 04, 2015 6:38 pm

Re: New to Raspberry, old to programming

Thu Mar 14, 2019 7:13 pm

Brian Beuken wrote:
Thu Mar 14, 2019 6:51 pm
editor/debugger with on target compiles are 100 times better, faster and easier to work with.
I use Linux on my x86 PC and the compiler, editor, debugger and other tools are identical.
Compiling is slower on the Pi it is true (especially C++) - despite the x86 PC being a few years old.

My x86 PC is a Core i7-3770K @ 3.50GHz with 16GB of RAM and a fast SSD.
On that PC I just measured C compilations at 8989 source code lines per second (GCC 8.3).

The Pi3B+ (also GCC 8.3) compiles 1448 source code lines per second, so the PC is around 6 times faster.

Sensible use of make means that's not too noticeable.

The Pi Zero that you are presumably thinking of is annoyingly slow it is true.

Over the years here I have seem many people get in a real pickle trying to sort out cross compilation and I am sure they could have completed their entire project in less time than they spend setting it up had they used the native tools!
It may well be easier now, I don't know.

Given the ridiculous difference in purchase price, electrical power consumption, physical size etc, I find the Pi is astonishingly good.
There is no question of it being "100 times worse" ...

User avatar
AdamStanislav
Posts: 147
Joined: Sun Mar 10, 2019 2:44 am
Location: Wisconsin
Contact: YouTube

Re: New to Raspberry, old to programming

Thu Mar 14, 2019 7:41 pm

Brian Beuken wrote:
Thu Mar 14, 2019 6:51 pm
Cross compiling can be a little tricky to set up
And are you going to tell us how to set it up? My main computer runs Windows 10x, I also have Cygwin on it, but I see nothing there that would let me cross compile anything for the Pi. I can easily compile Arduino code on Windows, but Raspberry Pi seems to be the best kept secret. Heck, even QtCreator says it has no idea how to compile for the Pi. From the Raspberry Pi web site I get the impression they only want it to be used by school kids but not by people who have been programming for decades. And they are pushing interpreters, like Python, instead of compiled languages, like C or assembly language.

Sorry, I just had to get the frustration off my old chest and my multi-stented heart.

jahboater
Posts: 4690
Joined: Wed Feb 04, 2015 6:38 pm

Re: New to Raspberry, old to programming

Thu Mar 14, 2019 7:44 pm

By the way, Qt Creator 5 runs fine, native, on the Pi as far as I can see ...

User avatar
AdamStanislav
Posts: 147
Joined: Sun Mar 10, 2019 2:44 am
Location: Wisconsin
Contact: YouTube

Re: New to Raspberry, old to programming

Thu Mar 14, 2019 8:14 pm

jahboater wrote:
Thu Mar 14, 2019 7:44 pm
By the way, Qt Creator 5 runs fine, native, on the Pi as far as I can see ...
It crashes on my 3B+.

jahboater
Posts: 4690
Joined: Wed Feb 04, 2015 6:38 pm

Re: New to Raspberry, old to programming

Thu Mar 14, 2019 8:24 pm

AdamStanislav wrote:
Thu Mar 14, 2019 8:14 pm
jahboater wrote:
Thu Mar 14, 2019 7:44 pm
By the way, Qt Creator 5 runs fine, native, on the Pi as far as I can see ...
It crashes on my 3B+.
Perhaps try it on Gentoo64 (which includes it pre-installed)?
https://github.com/sakaki-/gentoo-on-rpi3-64bit

User avatar
AdamStanislav
Posts: 147
Joined: Sun Mar 10, 2019 2:44 am
Location: Wisconsin
Contact: YouTube

Re: New to Raspberry, old to programming

Thu Mar 14, 2019 9:06 pm

Thanks, but I have other things on mine, such as Octoprint, which was actually what I bought mine for.

Brian Beuken
Posts: 177
Joined: Fri Jan 29, 2016 12:51 pm

Re: New to Raspberry, old to programming

Thu Mar 14, 2019 11:11 pm

AdamStanislav wrote:
Thu Mar 14, 2019 7:41 pm
Brian Beuken wrote:
Thu Mar 14, 2019 6:51 pm
Cross compiling can be a little tricky to set up
And are you going to tell us how to set it up? My main computer runs Windows 10x, I also have Cygwin on it, but I see nothing there that would let me cross compile anything for the Pi. I can easily compile Arduino code on Windows, but Raspberry Pi seems to be the best kept secret. Heck, even QtCreator says it has no idea how to compile for the Pi. From the Raspberry Pi web site I get the impression they only want it to be used by school kids but not by people who have been programming for decades. And they are pushing interpreters, like Python, instead of compiled languages, like C or assembly language.

Sorry, I just had to get the frustration off my old chest and my multi-stented heart.

i use VisualGDB for cross compiling. Its pretty much the mutts nuts,. www.visualgdb.com
It has a free 30 day trial, so you can give it a whirl, I find it works with very little effort.

try it..
I also use Visual Studios C++ for Linux, which allows editing and debugging on the PC, though compilation is still done on the Pi, its effective, free and allows more options for debugging. You can get some info on my website forum if you are interested.

I tend to agree with you on the pushing "simple" languages, but the Pi is a perfectly capable and fun machine to work on in C/C++ and OpenGLES2.0, using professional tools. I use it to give my 1st years a taste of restricted systems that force them to consider memory and processer power as limited resources. This serves then well when they move on to more powerful but equally closed and restricted console systems.

It is however perfectly capable of doing some very fun things, though there's little or no commerical outlets for projects. But its still a great training system for people who want to learn to code and push the limits of their machines.
Last edited by Brian Beuken on Thu Mar 14, 2019 11:37 pm, edited 2 times in total.
Very old computer game programmer, now teaching very young computer game programmers, some very bad habits.
Wrote some book about coding Pi's and SBC's, it's out now...go get it!
http://www.scratchpadgames.net/

Brian Beuken
Posts: 177
Joined: Fri Jan 29, 2016 12:51 pm

Re: New to Raspberry, old to programming

Thu Mar 14, 2019 11:34 pm

jahboater wrote:
Thu Mar 14, 2019 7:13 pm


Given the ridiculous difference in purchase price, electrical power consumption, physical size etc, I find the Pi is astonishingly good.
There is no question of it being "100 times worse" ...
The Pi is awesome, I love Pi's and other SBC's I've got dozens of them, from Zero's to Pi3b+ and much more powerfful intel based SBC's, but coding on your Pi, while perfectly possible and a good starting point to learn, especially if you just don't have another system to use as your development system, is just taking the hard road. I much prefer a simpler, faster, more effective toolchain.

And speed isn't just measured in the number of lines per second the compiler manages, its in ease of turnaround from hitting compile to the stopped breakpoints you can step through on your PC and visualise watches, data dumps and variable values, while watching the progress on your Pi. If you're doing a full screen project on Pi, you obscure your debugger (if you have one)

In terms of ease of development and turnaround debugging, profiling etc... I'd say working on a PC is actually 1000 times easier.. In fact I'd say working on any system, but sending to a target, is 1000 times easier. If I could work out how to connect 2 Pi's and use one as a dev system and other other as a target I'd be more than happy with that setup.
The PC is indeed much more expensieve, used more power and so on, but it is considerably better and easier to use than a Pi for development purposes. I guess it depends on what you value, power, price...or simple ease of workflow.


Bottom line, professional tools, make it a lot easier to work on projects, helps with debugging, keeps your project better organised, allows you to easily edit and access resources and a host of other benefits..

I grew up coding on ZX81's spectrums and amstrads using hisoft assembers and tape loading... the sheer joy of using a text screen 286PC with PDS hooked up to my specturm and being able to code and compile with no delay has never left me. Its by far the best way to work.
Very old computer game programmer, now teaching very young computer game programmers, some very bad habits.
Wrote some book about coding Pi's and SBC's, it's out now...go get it!
http://www.scratchpadgames.net/

User avatar
AdamStanislav
Posts: 147
Joined: Sun Mar 10, 2019 2:44 am
Location: Wisconsin
Contact: YouTube

Re: New to Raspberry, old to programming

Fri Mar 15, 2019 12:44 am

Thanks, Brian. I am just wondering if there is a gcc cross compiler available for Windows to compile for the RPi. Presumably, gcc is supposed to be able to compile for just about anything. And of course it can compile for the RPi on the RPi (and it does a very good job at optimizing, too), so in theory it should just be a matter of compiling it to run on Windows and still produce RPi object files.

Brian Beuken
Posts: 177
Joined: Fri Jan 29, 2016 12:51 pm

Re: New to Raspberry, old to programming

Fri Mar 15, 2019 1:59 am

as I say, www.VisualGDB.com you can use the toolchain to compile on the PC, or download the source to compile on the Pi, but debug on the PC, it works with the free community version of Visual Studio and is free for 30 days, and reasonably priced when the trial runs out.

Setting up Arm GCC on PC though, is just too much of a pain, yes it can be done, but I much prefer the VistualGDB approach, download, install and go...not too much messing about and all the tools you need to code, debug and deploy
Very old computer game programmer, now teaching very young computer game programmers, some very bad habits.
Wrote some book about coding Pi's and SBC's, it's out now...go get it!
http://www.scratchpadgames.net/

User avatar
AdamStanislav
Posts: 147
Joined: Sun Mar 10, 2019 2:44 am
Location: Wisconsin
Contact: YouTube

Re: New to Raspberry, old to programming

Fri Mar 15, 2019 3:09 am

I’m retired, I’m not going to pay for something so I can write free software for the Pi. So, I guess the anwer to my question is no. I’ll just write the code on my PC and compile it on the Pi, or just do it all on the Pi, then.

User avatar
AdamStanislav
Posts: 147
Joined: Sun Mar 10, 2019 2:44 am
Location: Wisconsin
Contact: YouTube

Re: New to Raspberry, old to programming

Fri Mar 15, 2019 4:17 am

And it looks like I may have found the answer to my question (I think I did, but am still downloading it, so cannot be 100% certain: http://gnutoolchains.com/raspberry/ by the same people that make VisualGDB, but this one seems free (it even includes a section oncompiling it all yourself, which would certainly be free, but what I am downloading right now is precompiled).

User avatar
AdamStanislav
Posts: 147
Joined: Sun Mar 10, 2019 2:44 am
Location: Wisconsin
Contact: YouTube

Re: New to Raspberry, old to programming

Fri Mar 15, 2019 4:54 am

And I just want to confirm that it, indeed, installs all the necessary compilers and utilities to compile/assemble and link RPi software on Windows. It also includes all the standard RPi libraries. 8-)

And since it is Midnight here in Wisconsin, I can now go to bed. :lol:

jahboater
Posts: 4690
Joined: Wed Feb 04, 2015 6:38 pm

Re: New to Raspberry, old to programming

Fri Mar 15, 2019 8:05 am

A common situation on the Pi is someone wanting to experiment with physical computing, or simply learning Python or C.

I am afraid I cannot see how it is 1000 times easier to spend days installing tool chains, cross compiler, cross debugger, etc in order to build a few lines of code (with no GUI typically) for the Pi.

There are all the tools needed on the Pi, preinstalled, ready to use, and free of charge.

KISS!

And of course the PC has no GPIO ...
Brian Beuken wrote:
Fri Mar 15, 2019 1:59 am
as I say, www.VisualGDB.com you can use the toolchain to compile on the PC, or download the source to compile on the Pi, but debug on the PC, it works with the free community version of Visual Studio and is free for 30 days, and reasonably priced when the trial runs out.
I assume VisualGDB just uses the "real" GDB on the Pi to do its actual work. I hope it adds some useful functionality for the money, given that all of GDB's (admittedly complex and possibly not so easy to use) power is available for free on the Pi.

I stopped using MSVC a few years ago and changed to GCC on Windows (mingw) which was like a breath of fresh air. MS stated intention not to keep up with the language standards did not help (the free GCC compiler fully supports all the latest standards for several languages). Now I use Linux on all my PC's, so no longer an issue.

I can see the motivation for using the PC if you are familiar with, and comfortable with, Visualxxx already - especially the editors.

What is wrong of course is the assumption some people have that because the Pi costs $35 and is the size of a credit card, it is inferior for software development.
Brian Beuken wrote:
Thu Mar 14, 2019 11:34 pm
I grew up coding on ZX81's spectrums and amstrads using hisoft assembers and tape loading... the sheer joy of using a text screen 286PC with PDS hooked up to my specturm and being able to code and compile with no delay has never left me. Its by far the best way to work.
Yes - like the move from punched cards to a direct terminal on a mainframe.
Having an assembler for the Z80 was a luxury - I remember programming it in hex machine code ....

cmrincon
Posts: 36
Joined: Thu May 24, 2018 7:39 pm

Re: New to Raspberry, old to programming

Fri Mar 15, 2019 10:08 am

Hi!
If you can install Visual Studio 2017 you can crosscompile and debug for your rpi WITHOUT visual gdb.

Buying visual gdb is obiusly easier but there are more ways to archieve your goal.

you will also need this: http://gnutoolchains.com/raspberry/
I recomend you to upgrade to windows 7 as visual studio 2017 can be installed in windows 7. I don't know if vs2017 can be installed in windows xp.

Brian Beuken
Posts: 177
Joined: Fri Jan 29, 2016 12:51 pm

Re: New to Raspberry, old to programming

Fri Mar 15, 2019 11:02 am

jahboater wrote:
Fri Mar 15, 2019 8:05 am
A common situation on the Pi is someone wanting to experiment with physical computing, or simply learning Python or C.

I am afraid I cannot see how it is 1000 times easier to spend days installing tool chains, cross compiler, cross debugger, etc in order to build a few lines of code (with no GUI typically) for the Pi.

There are all the tools needed on the Pi, preinstalled, ready to use, and free of charge.

KISS!
I'm really not saying you cannot work on the Pi, I'm simply saying its way more effort than you need. If you only want to do a small control project in C, or manage a few classes you can indeed use the onboard systems, or as I did in my MagPi tuts, install Code::Blocks to make managing a modest sized project easier.. But for larger projects working on your system simply gets hard; files can get corrupted during dev, memory is filled by your IDE etc...
I adhere very much to KISS, and working on a larger project (more than 20 files/classes say, ) is considerably easier to manage on a dev system than it is on a target system.

And it takes 10mins to download and install VisualGDB to work on Visual Studio..and you can code your 1st projects instantly....not days....instant.

If you don't want to use VisualGDB, VisualStudio 2017 and 2019 has cross platform options for Linux, and Raspberry in particular which also allow you to develop code for your Pi. A little bit more complex than VisualGDB but still pretty straight forward and you can get your LED's on your GPIO blinking away in under 20 mins.

You stopped using Visual Studio some time ago jahboater...so I can understand you not being aware of these advances now.
Very old computer game programmer, now teaching very young computer game programmers, some very bad habits.
Wrote some book about coding Pi's and SBC's, it's out now...go get it!
http://www.scratchpadgames.net/

Return to “C/C++”