kenzo0619
Posts: 4
Joined: Fri Feb 02, 2018 12:16 am

How can I practice my code for RPI?

Fri Feb 02, 2018 12:20 am

Hello

I just launched my project on Raspberry Pi.

As it is very slow when I programming on, is there any IDE that I can try to compile first on windows ?

BTW, i need to use multiple threads

User avatar
topguy
Posts: 4774
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: How can I practice my code for RPI?

Fri Feb 02, 2018 11:48 am

code::blocks or QtCreator or VS Code seems like decent possibilities.
The tricky part might be to set up GCC on windows for these environments but you'll probably find guides for that.

( All three of these also can run on the Pi afaik )

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

Re: How can I practice my code for RPI?

Fri Feb 02, 2018 1:17 pm

kenzo0619 wrote:
Fri Feb 02, 2018 12:20 am
I just launched my project on Raspberry Pi.

As it is very slow when I programming on, is there any IDE that I can try to compile first on windows ?

BTW, i need to use multiple threads
What model of Pi (if you are not using a Pi3, then get one ASAP!!! - the Pi Zero's are 8-10x slower).
How big is your program?
A 1000 line C program should take roughly 0.6 sec to compile on a Pi3 with full optimization, much less for debugging, and thats just using one core. Fast enough for most small Pi projects.

If you programs is sensibly structured, then you can use make -j4 to build on all four CPU's simultaneously (and obviously make will avoid any unneeded compilations, it will just do the minimum, often just the one module you have altered).

Multiple threads are not an issue of course. (In fact the Pi3 and Pi2 have four cores, so can execute the first four threads in parallel).

1dot0
Posts: 430
Joined: Mon Nov 28, 2016 12:31 pm

Re: How can I practice my code for RPI?

Sat Feb 03, 2018 9:06 am

kenzo0619 wrote:
Fri Feb 02, 2018 12:20 am
Hello

I just launched my project on Raspberry Pi.

As it is very slow when I programming on, is there any IDE that I can try to compile first on windows ?

BTW, i need to use multiple threads
use Geany, it's already pre-installed by Jessie or Stretch (Desktop menu, tools)

preferences:
compile: gcc -Wall -c "%f"
build: gcc -Wall -o "%e" "%f"
execute: "sudo ./%e"


multiple threads:
#include <pthread.h>

adjust build preferences in Geany:
build: gcc -Wall -pthread -o "%e" "%f"


now you can
compile: by F8,
build: by F9 and
execute: by F5


if you want C++ instead of ANSI C:
exchange gcc by g++ in the Geany preferences, rest stays as it was.


edit,
some functions need root rights for execution, e.g. hardware pwm and perhaps i2c or some more - I often had troubles without it, and eventually sudo wouldn't matter. But one may try execute also without sudo of course.

edit2:
I first was missing the Windows option, but Geany is also available for Windows, too.
Last edited by 1dot0 on Mon Feb 05, 2018 6:25 pm, edited 4 times in total.

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

Re: How can I practice my code for RPI?

Sat Feb 03, 2018 9:09 am

Why is sudo needed to execute the program?

1dot0
Posts: 430
Joined: Mon Nov 28, 2016 12:31 pm

Re: How can I practice my code for RPI?

Sat Feb 03, 2018 9:13 am

some functions need root rights, e.g. hardware pwm and perhaps i2c or some more - I often had troubles without it, and eventually sudo wouldn't matter.

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

Re: How can I practice my code for RPI?

Sat Feb 03, 2018 9:17 am

OK fair enough.
It just seemed dangerous to me to use it for everything.
At best, any files created become owned by root.

User avatar
topguy
Posts: 4774
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: How can I practice my code for RPI?

Mon Feb 05, 2018 9:51 am

Yes, dont use sudo, its usually not needed.
Access to hardware can be granted to the "pi" user by changing which "groups" he belongs to.

1dot0
Posts: 430
Joined: Mon Nov 28, 2016 12:31 pm

Re: How can I practice my code for RPI?

Mon Feb 05, 2018 10:54 am

just to clarify:
the setting in the Geany preferences
execute: "sudo ./%e"
was just for starting programs out of the IDE (pressing F5), just for convenience reasons, and not for general purposes to start either program.
I never had issues by that, not even when wiringI2c once (for a long time) required that cmpellingly, so as to me I'll stay with that setting.
Other people may decide of course just how they wish to.

AdrianG001
Posts: 1
Joined: Mon Feb 05, 2018 3:48 pm

Re: How can I practice my code for RPI?

Mon Feb 05, 2018 4:00 pm

I use either gedit (has windows version available) or more commonly SharpDevelop. SharpDevelop is more intended as a .net IDE but comes with ironPython (python 2 for .net) support. Its usually overkill but full intellisense support is awesome aswell as code conversion to C#, VB.net and ironRuby. If your looking to use python in windows only programs then ironpython is probably the way to go anyway, its usually faster.

The .py files for ironPython are identical to those of regular python so you should be fine to use sharpdevelop as long as you don't use any of the additional ironpython functionality.

Adrian Gates
Sr. Windows Admin - Apps4Rent.com

Daniel Gessel
Posts: 21
Joined: Sun Dec 03, 2017 1:47 am

Re: How can I practice my code for RPI?

Mon Feb 05, 2018 5:42 pm

I’m going slightly off topic since the OP asked about Windows, but cosider installing a Linux distro (Raspbian itself is an option) on your desktop for increased compatibility while getting your desktop’s performance for development (I don’t find compile times an issue, but everybody has their own process).

ProgrammingPescador
Posts: 14
Joined: Sat Aug 05, 2017 12:00 pm
Location: UK

Re: How can I practice my code for RPI?

Sun Feb 11, 2018 12:05 pm

Hi

This probably goes against the grain, but I use Visual Studio 2017 and write all my C code using the C/C++ cross platform project option. I find it works well and building and debugging use gcc and gdb on the target. If you use any non standard include files you will need to copy them to your development machine and update VC++ directories option for intellisense to work and stop VS from telling you the files do not exist.


https://blogs.msdn.microsoft.com/vcblog ... al-studio/
https://blogs.msdn.microsoft.com/vcblog ... velopment/
The ProgrammingPescador

ejolson
Posts: 1843
Joined: Tue Mar 18, 2014 11:47 am

Re: How can I practice my code for RPI?

Sun Feb 11, 2018 7:55 pm

Daniel Gessel wrote:
Mon Feb 05, 2018 5:42 pm
I’m going slightly off topic since the OP asked about Windows, but cosider installing a Linux distro (Raspbian itself is an option) on your desktop for increased compatibility while getting your desktop’s performance for development (I don’t find compile times an issue, but everybody has their own process).
It would be logical for Raspbian x86 to have an ARM cross-compiler, emulation and development environment installed by default. If that ever happens, the answer to this question would be as follows: Install Raspbian x86 in VirtualBox under Windows. Then click on the icon "development tools for creating ARM binaries" that is already installed. Until then, compilation speed on a Pi 3B can often be increased by using a fast USB drive for the root filesystem instead of an SD card.

Return to “C/C++”

Who is online

Users browsing this forum: No registered users and 5 guests