Page 1 of 2

Running C/C++ on Raspberry Pi

Posted: Wed Oct 02, 2019 7:19 am
by nick8967
Hello,

I want to write code on C/C++ on Rpi 3 B+. Is there any reliable IDE to help me on that? Is C/C++ officially supported (as python) by Rpi or I should do "tricks" and result in doing nothing? Of course I will use libraries on C/C++ so I search for a "mainstream" solution...

Any suggestion?

Thank you

Re: Running C/C++ on Raspberry Pi

Posted: Wed Oct 02, 2019 7:53 am
by jahboater
nick8967 wrote:
Wed Oct 02, 2019 7:19 am
or I should do "tricks" and result in doing nothing?
Interesting to know what these "tricks" are ?

Re: Running C/C++ on Raspberry Pi

Posted: Wed Oct 02, 2019 7:54 am
by Heater
The Pi runs Raspbian which includes GCC, The GNU Compiler Collection, which compiles C and C++ among other languages. You cannot get more mainstream than GCC.

I try to avoid using IDE's but Microsoft's Visual Studio Code is a greate whiich supports pretty much anything you need from an IDE with extensions. VS Code is open source and runs on Linux, Mac and Windows. I hear it runs on the Pi as well.

Re: Running C/C++ on Raspberry Pi

Posted: Wed Oct 02, 2019 8:40 am
by nick8967
The best optimization I can get is with gcc or with Visual Studio?

Thanks

Re: Running C/C++ on Raspberry Pi

Posted: Wed Oct 02, 2019 9:45 am
by Heater
Your question makes no sense gcc is a compiler, Visual Studio is an IDE.

As as far as I know MicroSoft's compiler MSVCC cannot generate code to run on a Pi using Raspbian.

GCC is a high quality, industry standard C/C++ compiler with very good optimizatiion.

Almost certainly the code you write will have more effect on performance than any difference between compilers.

Re: Running C/C++ on Raspberry Pi

Posted: Wed Oct 02, 2019 10:29 am
by markkuk
nick8967 wrote:
Wed Oct 02, 2019 8:40 am
The best optimization I can get is with gcc or with Visual Studio?
Visual Studio Code is a completely different program from Visual Studio. Visual Studio Code is a cross-platform code editor with plugins that enable IDE-like properties. It doesn't include a compiler for any language. If you write C or C++ with VSCode you need to use GCC or Clang as the compiler.

Re: Running C/C++ on Raspberry Pi

Posted: Wed Oct 02, 2019 10:36 am
by jahboater
nick8967 wrote:
Wed Oct 02, 2019 8:40 am
The best optimization I can get is with gcc or with Visual Studio?
GCC is pre-installed and ready to use.
Clang is an alternative that may be installed if desired.

The optimization done by GCC is class leading.
You can easily examine the assembler code emitted. If you are familiar with assembler, you will likely be very surprised how clever the compiler is.

GCC on the Pi supports many languages:
C, Ada, C++, Go, D, Fortran, Objective C, Objective-C++

GCC also has full support for the latest language standards such as C18 and C++17, which MSVC will never have.

GCC is considered by many to be the gold standard.

In summary, I suggest just use GCC, it will do everything you want and more.

Re: Running C/C++ on Raspberry Pi

Posted: Wed Oct 02, 2019 11:41 am
by nick8967
Sorry, but objective C/C++ doesn't run only on macbooks??

Re: Running C/C++ on Raspberry Pi

Posted: Wed Oct 02, 2019 11:54 am
by PeterO
nick8967 wrote:
Wed Oct 02, 2019 11:41 am
Sorry, but objective C/C++ doesn't run only on macbooks??
I can't tell if that is that a statement or a question.
But....
Objective-C will run on lots of platforms.
PeterO

Re: Running C/C++ on Raspberry Pi

Posted: Wed Oct 02, 2019 11:57 am
by B.Goode
nick8967 wrote:
Wed Oct 02, 2019 11:41 am
Sorry, but objective C/C++ doesn't run only on macbooks??

https://gcc.gnu.org/onlinedocs/gcc/Obje ... tions.html

Note that the poster didn't make any claim about that being a useful option on a Raspberry Pi, only that it was a feature of the GCC compiler.

Re: Running C/C++ on Raspberry Pi

Posted: Wed Oct 02, 2019 12:53 pm
by dsyleixa123
nick8967 wrote:
Wed Oct 02, 2019 7:19 am
Hello,

I want to write code on C/C++ on Rpi 3 B+. Is there any reliable IDE to help me on that? Is C/C++ officially supported (as python) by Rpi or I should do "tricks" and result in doing nothing? Of course I will use libraries on C/C++ so I search for a "mainstream" solution...

Any suggestion?

Thank you
a IDE for compilers to C (gcc) and C++ (g++) is the IDE Geany, it's easy, simple, handy, and already pre-installed.
Grafic IDEs (GUI-IDEs) like Visual Studio for Windows which work for Linux e.g. are qt creator, gtk, openCV - but for a beginner they are real monsters...

A tutorial for C/C++ using Geany e.g. is this one: http://fractal.math.unr.edu/~ejolson/pi ... dified.pdf

(note that you can build and run the executables directly out of Geany (internally), or instead do that build and run (externally) out of a terminal window).

Re: Running C/C++ on Raspberry Pi

Posted: Mon Oct 14, 2019 10:46 pm
by jachaney
If you are on a Raspberry Pi, It is best to use Code:Blocks for an IDE, and start with a simple console application for the "hello, world!" I can be installed easily using
`sudo apt-get install codeblocks`

Look up GTK+ documentation for making GUI based applications. I use the 2.0 version and downloaded the development libraries with `sudo apt-get install libgtk2.0-dev`. Then added `pkg-config --cflags gtk+-2.0` to the include path, and `pkg-config --libs gtk+-2.0` to the additional libraries.

Re: Running C/C++ on Raspberry Pi

Posted: Tue Oct 15, 2019 12:10 am
by HermannSW
My IDE for C/C++ is
  • vi (editor, use it since 1990)
  • gcc/g++ (compiler)
  • gdb (debugger)
  • make
  • (git)
I don't need more than that.

Re: Running C/C++ on Raspberry Pi

Posted: Tue Oct 15, 2019 12:49 am
by jahboater
HermannSW wrote:
Tue Oct 15, 2019 12:10 am
My IDE for C/C++ is
  • vi (editor, use it since 1990)
  • gcc/g++ (compiler)
  • gdb (debugger)
  • make
  • (git)
I don't need more than that.
+1 !!

Except that I use a home written editor instead of vi.

Re: Running C/C++ on Raspberry Pi

Posted: Tue Oct 15, 2019 2:30 am
by jachaney
I too was a "basic text editor" VI coder. Waged battles of VI v. Emacs. Scripting v. compiled. Writing macros, and shortcuts, for common operations. Wrote my own make make. The thing is, if I can use a tool to make my life easier, and get me to the finish line quicker, I will use it. GIT is fashionable these days, but I have used Mercurial for several years, so I am used to it.

I was an early adopter of Eclipse, mostly because I was doing a lot of Java stuff back then. I tried running Eclipse on the Pi, and it does work pretty well, but I ran into some library problems with the new version of VM from Oracle, so I switched over to Code:Blocks. I miss some of the mechanisms that Eclipse had, but the small size and speed make up for it.

Running C/C++ on Raspberry Pi, is no different than running it on any Linux based system, so I was providing the quickest and easiest way to produce code, of non-trivial content. True a single file "hello, world!" can be done fully from the command line with a basic editor, but if the program has a high level of complexity, and uses multiple libraries, an IDE helps keep things orderly.

Jack

Re: Running C/C++ on Raspberry Pi

Posted: Tue Oct 15, 2019 8:24 pm
by DougieLawson
HermannSW wrote:
Tue Oct 15, 2019 12:10 am
My IDE for C/C++ is
  • vi (editor, use it since 1990)
  • gcc/g++ (compiler)
  • gdb (debugger)
  • make
  • (git)
I don't need more than that.
Same here.
Except, I use cmake because I really don't like Makefiles and cmake takes away that pain.

Re: Running C/C++ on Raspberry Pi

Posted: Tue Oct 15, 2019 9:12 pm
by dsyleixa123
vi is really a cumbersome crutch from times when the rock'n'roll was invented and which honestly makes me vomite - instead, Geany is a handsome and reasonable editor and IDE.

Re: Running C/C++ on Raspberry Pi

Posted: Tue Oct 15, 2019 11:55 pm
by jcyr
dsyleixa123 wrote:
Tue Oct 15, 2019 9:12 pm
vi is really a cumbersome crutch from times when the rock'n'roll was invented and which honestly makes me vomite - instead, Geany is a handsome and reasonable editor and IDE.
Try running that in an terminal window via SSH.

Re: Running C/C++ on Raspberry Pi

Posted: Wed Oct 16, 2019 12:37 am
by Paeryn
dsyleixa123 wrote:
Tue Oct 15, 2019 9:12 pm
vi is really a cumbersome crutch from times when the rock'n'roll was invented and which honestly makes me vomite - instead, Geany is a handsome and reasonable editor and IDE.
I somehow doubt the honesty of your said reaction to vi. There's nothing wrong with vi (though vim has replaced vi nowadays) although for some strange reason vim-basic is the default installed version (probably more compatible with the original vi). The first thing I do is uninstall that and install the full-fat vim, there's so much of vim missing in vim-basic that I'm sure vim-basic puts newcomers off.

There's gvim as well for when you want a gui rather than console interface. Then again I've been using vim (and emacs) for over 25 years so I'm used to them.

Re: Running C/C++ on Raspberry Pi

Posted: Wed Oct 16, 2019 3:55 am
by Heater
dsyleixa123,

Oh for goodness sake. Rock'n'roll arrived in the early 1950s and even before that. Vi did not arrive til the late 1970s

There are so many situations where a "handsome and reasonable editor and IDE" will not work and is of no use what so ever that is very useful to have vi/vim available. It's not a crutch it's a useful, powerful and often essential tool.

If you took the trouble to find out you will discover that vim can run rings around Geany, for example, in terms of functionality and productivity.

Or were you just trolling? I always fall for it...

Re: Running C/C++ on Raspberry Pi

Posted: Wed Oct 16, 2019 5:26 am
by rpdom
Vi used to be the editor you could depend on being available on pretty much any *nix based system - even in recovery mode.

Although recently I worked on systems that had nano instead of vi. That confused me. I installed a minimal vi as soon as I could on them.

Anyone who is likely to do any sysadmin roles at any point should try to learn just basic vi usage.

Re: Running C/C++ on Raspberry Pi

Posted: Wed Oct 16, 2019 6:31 am
by DougieLawson
Paeryn wrote:
Wed Oct 16, 2019 12:37 am

The first thing I do is uninstall that and install the full-fat vim, there's so much of vim missing in vim-basic that I'm sure vim-basic puts newcomers off.
Exactly what I do. I'll see if I can lobby the RPF folks (in the same way I did for ntfs-3g) to get that fixed.

Re: Running C/C++ on Raspberry Pi

Posted: Wed Oct 16, 2019 7:11 am
by dsyleixa123
haha, I had bet that my post would provoke those answers :D
But for programming I never use terminal windows and neither ssh, for programming on the Pi one would need a mouse, a comfortable File menu, several tabs, colored code highlighting, symbols and docs side bar, auto-intend, check for brackets/nesting levels, compile-error checking and highlighting feat. a jump to either code line a.s.o., compile+build+run out of the IDE, and that is just what Geany is providing.
OTOH, code::blocks does even much more, and actually that is already far too much for beginners and hobby programmers.

Re: Running C/C++ on Raspberry Pi

Posted: Wed Oct 16, 2019 7:44 am
by Heater
dsyleixa123,

Well done Sir. Excellent troll.

Meanwhile:
For programming on the Pi one would need a mouse, a comfortable File menu, several tabs, colored code highlighting, symbols and docs side bar, auto-intend, check for brackets/nesting levels, compile-error checking and highlighting feat. a jump to either code line a.s.o., compile+build+run out of the IDE,
Wow, did you say vim was a crutch? How many crutches do you need to make any progress? It's amazing you can even stand up.

As it happens Vim can do all of that.

Damn that nano thing. It turns up everywhere now. Who thought that was good idea?

Re: Running C/C++ on Raspberry Pi

Posted: Wed Oct 16, 2019 7:57 am
by dsyleixa123
vi with a mouse and colored code highlighting and compile+run out of the program a.s.o...?
If I type vi in the console it's just an ugly b+w text-box.
(ok, nano is surely even worse, actually not even worth mentioning...)

PS,
and don't forget: this topic is about a beginner to C(++) programming on the Pi who is asking about an IDE.
Even the MagPi C tutorial is using Geany.