Author Topic: all i want to do is run a C++ example  (Read 6209 times)

0 Members and 1 Guest are viewing this topic.

Online SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17728
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: all i want to do is run a C++ example
« Reply #50 on: February 07, 2023, 10:36:19 pm »
That's a good point, quite a few microcontrollers IDE's just use C.
Yes, but it's not the reason I implied. To write code for microcontrollers it's possible to use any language for which there is a compiler producing native machine code or a way to execute interpreted code: in this regard C and C++ are equal.

C++ is a great language, but does one *really* need all of its bells and whistles? In case C is thought inappropriate from the perspective of making simple things look difficult (yes, it's actually true, to a certain extent), then C++ won't make much of a difference from this point of view, and a higher level language would probably be more suitable and easier to grasp.

Of course if the goal is to learn C++, then the suggestion to use any other language makes no sense. I'm not sure whether it's the case though (the case still remains a bit unclear to me).

update: after re-reading some posts, I finally understand that the goal is exactly what is stated in the thread title, *but* at the same time following what is written in a book. In this case, there's no other way than to follow the book and go through the pain of installing the required IDE and everything.

Microchip studio which actually is just VS with atmel/microchip setup uses the GCC compiler for ARM and will take C and C++, even when adding just a C file you are actually adding a C/C++ file as it does not distinguish, the compiler is C++ and as such that I understand it will also compile C.

As I said further back in my attempts to make code as reusable as possible and flexible I have often come asking questions about what I can do. The answers have often been that in C you can't do that but essentially what I am asking to do is what C++ does. i have also noticed that a lot of ARM libraries are available as C++ only. So at least looking at C++ sounds like a good idea.

Oh, and yes I did try VS, still failed.
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 9889
  • Country: nz
Re: all i want to do is run a C++ example
« Reply #51 on: February 07, 2023, 10:38:39 pm »
I've not read this entire thread,
but if you;
- Just want something quick to install to play around with C++ making windows or command line apps.
- Want something that has everything you need in one install, and will work out of the box

Then you could download the  "Embarcadero C++ Builder Community Edition."
It's basically the free/starter edition using the IDE that Delphi uses but with full C++ compiler.
(The company that makes Delphi have both C++ and Pascal(delphi) versions)

https://www.embarcadero.com/products/cbuilder/starter
Greek letter 'Psi' (not Pounds per Square Inch)
 

Online SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17728
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: all i want to do is run a C++ example
« Reply #52 on: February 07, 2023, 10:39:43 pm »
You don't need all of the features (or even most of them), but some features like concrete classes, constructors, function overloading, even basic templates, can be very helpful.
Sure they can. As well as in nearly any modern OO language. The question was more like whether this is required for a specific task, but since the task is to run a C++ example, obviously it can't be done in any other language than C++.

The task I have set myself is to explore C++, as a starter for 10 and without wondering if I am at fault or something else is wrong, running an example is the place to start, or am I wrong?

 

Online SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17728
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: all i want to do is run a C++ example
« Reply #53 on: February 07, 2023, 10:40:21 pm »
I've not read this entire thread,
but if you;
- Just want something quick to install to play around with C++ making windows or command line apps.
- Want something that has everything you need in one install, and will work out of the box

Then you could download the  "Embarcadero C++ Builder Community Edition."
It's basically the free/starter edition using the IDE that Delphi uses but with full C++ compiler.
(The company that makes Delphi have both C++ and Pascal(delphi) versions)

https://www.embarcadero.com/products/cbuilder/starter

i will try, but several people have said the same thing about different things.
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 9889
  • Country: nz
Re: all i want to do is run a C++ example
« Reply #54 on: February 07, 2023, 10:42:05 pm »
You don't need all of the features (or even most of them), but some features like concrete classes, constructors, function overloading, even basic templates, can be very helpful.
Sure they can. As well as in nearly any modern OO language. The question was more like whether this is required for a specific task, but since the task is to run a C++ example, obviously it can't be done in any other language than C++.

The task I have set myself is to explore C++, as a starter for 10 and without wondering if I am at fault or something else is wrong, running an example is the place to start, or am I wrong?

Embarcadero C++ Builder Community Edition will do that just fine. and it's graphical IDE, you can drag buttons/components onto the main application form and add C++ code for onclick event etc..  And of course you can get complex and create your own classes/objects etc..
Greek letter 'Psi' (not Pounds per Square Inch)
 

Online shapirus

  • Super Contributor
  • ***
  • Posts: 1167
  • Country: ua
Re: all i want to do is run a C++ example
« Reply #55 on: February 07, 2023, 10:44:25 pm »
The task I have set myself is to explore C++, as a starter for 10 and without wondering if I am at fault or something else is wrong, running an example is the place to start, or am I wrong?
That's perfectly fine, only there seem to be some difficulty in getting started with a particular IDE or something. I suggested one way of trying it (sure it's not for everybody) that bypasses the IDE whatsoever; if it doesn't work, then there's a windows-native way, for example described step by step in post #40. I didn't try it, but it looks quite straightforward to me. What is it exactly of the steps listed there that fails for you?
 

Offline IanB

  • Super Contributor
  • ***
  • Posts: 11790
  • Country: us
Re: all i want to do is run a C++ example
« Reply #56 on: February 07, 2023, 10:48:02 pm »
Oh, and yes I did try VS, still failed.

Please tell us you did what langwadt did in reply #40, and if it failed, what went wrong?

And as a reminder, what you described at the top of this thread was not Visual Studio.
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 9889
  • Country: nz
Re: all i want to do is run a C++ example
« Reply #57 on: February 07, 2023, 10:48:50 pm »
Different people learn in different ways.
Some people just want something easy to get started with, doesn't matter what it is, just needs to be effortless to get started.
It's very annoying when you make the decision to learn something and there is a big wall to overcome in order to even create "hello world".
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline Sherlock Holmes

  • Frequent Contributor
  • **
  • !
  • Posts: 570
  • Country: us
Re: all i want to do is run a C++ example
« Reply #58 on: February 08, 2023, 03:55:16 am »
Install Visual Studio (community edition or a paid subscription) edition. Now, to work on microcontrollers, go and get VisualGDB, it is absolutely superb quality, these guys know their subject.

VisualGDB will install EVERYTHING needed, I had code running on an STM32 board within 15 minutes after installing VisualGDB, let me know how it goes, I've used Visual Studio for C development for over thirty years, so I'm sure I can help you.

Microsoft use Visual Studio and their C and C++ compilers to maintain Windows, kernel mode device drivers and Visual Studio itself. I too hate the stupid name "Visual Studio Code", it's about as unhelpful as a name could be.

Finally, are you sure you want to learn C++? why? unless you have to, I wouldn't waste the time, there are far better languages to spend your time on, seriously.
« Last Edit: February 08, 2023, 04:04:51 am by Sherlock Holmes »
“When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.” ~ Arthur Conan Doyle, The Case-Book of Sherlock Holmes
 

Online SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17728
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: all i want to do is run a C++ example
« Reply #59 on: February 08, 2023, 09:04:52 am »
I will have another look tonight. When i looked into doing things like running a file system on an SD card all I found were C++ libraries, so I reasoned I need to learn C++. In the same way I started learning C as that is what everyone else was using and all I could talk to them about, I had started out using BASIC on a PIC, worked for me, but I seemed rather alone.
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12806
Re: all i want to do is run a C++ example
« Reply #60 on: February 08, 2023, 09:21:27 am »
I'm surprised you couldn't find a filesystem driver that doesn't need C++

One of the most well-known reasonably lightweight ones suitable for lower resources embedded systems is Elm Chan's FatFs, which is coded in ANSI C89, as historically many embedded cross-compilers have lagged behind mainstream C, and small embedded system C99 support was uncommon as recently as a decade ago.

 
The following users thanked this post: nctnico

Online nctnico

  • Super Contributor
  • ***
  • Posts: 26751
  • Country: nl
    • NCT Developments
Re: all i want to do is run a C++ example
« Reply #61 on: February 08, 2023, 09:36:30 am »
I will have another look tonight. When i looked into doing things like running a file system on an SD card all I found were C++ libraries, so I reasoned I need to learn C++. In the same way I started learning C as that is what everyone else was using and all I could talk to them about, I had started out using BASIC on a PIC, worked for me, but I seemed rather alone.
Still, I'm wondering what other development tools you already have installed. If you already have an eclipse based IDE (like ST's Cube), then all you need to get going is to install the MingW64 compiler package. Some people don't like Eclipse but the fact is that most microcontroller IDEs are Eclipse based nowadays so using that keeps you close at home so to say. The nice thing about Eclipse is that you can always create other projects than the microcontroller specific ones so you can use ST's cube to also write applications that run on a PC. I'm doing that all the time to create test benches for code.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline Kalvin

  • Super Contributor
  • ***
  • Posts: 2145
  • Country: fi
  • Embedded SW/HW.
Re: all i want to do is run a C++ example
« Reply #62 on: February 08, 2023, 11:32:09 am »
My 2c: Visual Code Studio + Platformio might be one alternative to get up & running. The development framework is available for both Windows & Linux, so you do not have to force yourself into Linux. There are plenty of tutorials and videos floating around (although not all are created equal in terms of quality). A huge number of processors, boards and frameworks are supported. Search engine and Youtube are your friends when getting started.
 

Offline Kalvin

  • Super Contributor
  • ***
  • Posts: 2145
  • Country: fi
  • Embedded SW/HW.
Re: all i want to do is run a C++ example
« Reply #63 on: February 08, 2023, 11:59:00 am »
About learning C++: I would suggest that you start reading a book about C++ for beginners that uses Windows as the development environment, and start learning C++ by creating and running simple programs in PC using text-based terminal input & output. After you have gained some experience in PC environment, you should be able gradually start developing for the embedded systems.
 
The following users thanked this post: Sherlock Holmes

Offline Sherlock Holmes

  • Frequent Contributor
  • **
  • !
  • Posts: 570
  • Country: us
Re: all i want to do is run a C++ example
« Reply #64 on: February 08, 2023, 03:32:10 pm »
I will have another look tonight. When i looked into doing things like running a file system on an SD card all I found were C++ libraries, so I reasoned I need to learn C++. In the same way I started learning C as that is what everyone else was using and all I could talk to them about, I had started out using BASIC on a PIC, worked for me, but I seemed rather alone.

Id' agree with others here that if you really wany to get to grips with C++ then step back from MCUs for now. Learning C++ on Windows by writing code under Visual Studio is definitely a wise way to do that. Only once you're comfortable and have made most of the silly mistakes should you move to an MCU. Windows is a robust OS, even terribly buggy C++ will not impact the OS's stability so you can just rerun and retest over and over more easily than on an MCU where a freeze-up is the norm with buggy code.

Frankly embracing C++ just because the first libraries you found were written in C++, isn't prudent, forget C++ if you can - IMHO anyway.
“When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.” ~ Arthur Conan Doyle, The Case-Book of Sherlock Holmes
 

Offline snarkysparky

  • Frequent Contributor
  • **
  • Posts: 414
  • Country: us
Re: all i want to do is run a C++ example
« Reply #65 on: February 08, 2023, 08:31:05 pm »
code blocks can be downloaded with compiler

ˆ Download the Code::Blocks installer (https://codeblocks.org/downloads/26).
If you know you don’t have MinGW installed, or if you don’t know which one to
choose, download the package which has MinGW bundled. For 20.03 version,
the name of the installer is: codeblocks-20.03mingw-setup.exe. Previous version was
identified by 17.12.
ˆ Run the installer, it’s a standard installer for Windows; just press Next after reading
each screen.
ˆ If you’re planning installing a compiler after you’ve installed Code::Blocks, read the
information provided in the installer.
ˆ If you downloaded the installer which doesn’t come with MinGW, you may have to
configure the compiler manually (usually Code::Blocks’ auto detects the compiler).
 

Offline eti

  • Super Contributor
  • ***
  • !
  • Posts: 1801
  • Country: gb
  • MOD: a.k.a Unlokia, glossywhite, iamwhoiam etc
Re: all i want to do is run a C++ example
« Reply #66 on: February 09, 2023, 04:36:11 am »
I am so pissed off. I am trying to learn C++, -step one, copy the first example code that is about 1 sentence long into visual studio code, 2 discover that visual studio code with C++ tools installed does not have a C++ compiler, 3 go around and around in fucking circles trying to find out how to install C++ in visual studio and got no where except being told to download visual studio - what is the difference?. Seriously ? do coders just take the fucking piss all the time???

How can it be so hard to just install an IDE with compiler??? and my junior colleague thinks I am a jkbit weird for preferring bare metal programming.

Simon, try nano and g++ - you can install them in a heartbeat if you install Linux on VirtualBox - never mind an IDE at this level. VS code can be a nightmare, yeah - I battled with it last year, but once you adjust it all falls into place.

Yes, programmers assume WAY TOO MUCH - that’s why they hide away and don’t see sunlight, and that has the unfortunate effect of them not learning social skills, ergo are unable to adequately translate not necessarily THAT difficult subjects into plain talk for people like us to grasp. Sadly, a huge number of them have gigantic egos, and that’s not helped by the fact that they’re seen as some form of “superhero” type person - and they oft wouldn’t deign to lower themselves to try and imagine being in the position they were in BEFORE they knew what they now do, and then patiently and calmly explain it, making no assumptions of their pupils. Very few do this, which is why the REAL heroes are those who’s stand out by bothering to do so.

It takes LOTS of effort and a natural, God-given gifting to be a clear, easy to follow teacher, and sadly the fact is that so many “tutorials” online are written/shot by people who vastly overestimate their natural talent for said technical teaching.
« Last Edit: February 09, 2023, 04:40:08 am by eti »
 

Offline Ed.Kloonk

  • Super Contributor
  • ***
  • Posts: 4000
  • Country: au
  • Cat video aficionado
Re: all i want to do is run a C++ example
« Reply #67 on: February 09, 2023, 04:42:32 am »
 :palm:
iratus parum formica
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 9889
  • Country: nz
Re: all i want to do is run a C++ example
« Reply #68 on: February 09, 2023, 04:45:56 am »
Simon, try nano and g++

What a troll  >:D
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline eti

  • Super Contributor
  • ***
  • !
  • Posts: 1801
  • Country: gb
  • MOD: a.k.a Unlokia, glossywhite, iamwhoiam etc
Re: all i want to do is run a C++ example
« Reply #69 on: February 09, 2023, 04:56:41 am »
Simon, try nano and g++

What a troll  >:D

Having strong views != being “a troll”.
Also can we please move on from idiotic, unimaginative internet phrases - we don’t call people with different views “trolls” in real life.

The internet and it’s “traditions” and the inability of people to escape them, is hilariously tragic.

Have some better words in your vocabulary!

https://www.reddit.com/r/unpopularopinion/comments/84wcu9/people_need_to_stop_calling_everyone_who/

Man up and grow up.
« Last Edit: February 09, 2023, 05:04:21 am by eti »
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 9889
  • Country: nz
Re: all i want to do is run a C++ example
« Reply #70 on: February 09, 2023, 05:02:11 am »
Wait, you are actually serious that he should use nano and a C++ compiler?

The amount of time needed to set that up and learn about makefiles goes against the OP requirement of something simple and quick to get up and running. By like an order of magnitude.
« Last Edit: February 09, 2023, 05:06:16 am by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 3996
  • Country: nz
Re: all i want to do is run a C++ example
« Reply #71 on: February 09, 2023, 05:05:18 am »
Different people learn in different ways.
Some people just want something easy to get started with, doesn't matter what it is, just needs to be effortless to get started.
It's very annoying when you make the decision to learn something and there is a big wall to overcome in order to even create "hello world".

Well, I agree!!!

Here are complete instructions to make and run a C++ program on Windows 10 version 2004 and higher (Build 19041 and higher) or Windows 11:

1) Open PowerShell or Windows Command Prompt in administrator mode by right-clicking and selecting "Run as administrator"

2) type "wsl --install". This will take some time.

3) type "bash".

4) type "apt install g++".  This will take less time.

5) paste:

Code: [Select]
cat >hello.cpp <<END
#include <stdio>
int main(){std::cout << "Hello!\n"; return 0;}
END
g++ hello.cpp -o hello
./hello

How freaking hard is that?
« Last Edit: February 09, 2023, 05:22:14 am by brucehoult »
 

Offline eti

  • Super Contributor
  • ***
  • !
  • Posts: 1801
  • Country: gb
  • MOD: a.k.a Unlokia, glossywhite, iamwhoiam etc
Re: all i want to do is run a C++ example
« Reply #72 on: February 09, 2023, 05:06:13 am »
Wait, you are actually serious that he should use nano and a C++ compiler?

The amount of time needed to set that up and get makefiles working goes against the OP requirement of something simple and quick to get up and running.

Why didn’t you spend that energy constructively helping Simon instead of destructively telling me I’m “wrong”?

Go and help him. If you don’t like my suggestion feel free too BUZZ ORFFF! 🐝
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 9889
  • Country: nz
Re: all i want to do is run a C++ example
« Reply #73 on: February 09, 2023, 05:07:36 am »
Wait, you are actually serious that he should use nano and a C++ compiler?

The amount of time needed to set that up and get makefiles working goes against the OP requirement of something simple and quick to get up and running.

Why didn’t you spend that energy constructively helping Simon instead of destructively telling me I’m “wrong”?

Go and help him. If you don’t like my suggestion feel free too BUZZ ORFFF! 🐝

I did help him, i give him a simple way to install something that would work out of the box a few posts ago.
Greek letter 'Psi' (not Pounds per Square Inch)
 
The following users thanked this post: Ed.Kloonk

Offline eti

  • Super Contributor
  • ***
  • !
  • Posts: 1801
  • Country: gb
  • MOD: a.k.a Unlokia, glossywhite, iamwhoiam etc
Re: all i want to do is run a C++ example
« Reply #74 on: February 09, 2023, 05:09:57 am »
Wait, you are actually serious that he should use nano and a C++ compiler?

The amount of time needed to set that up and get makefiles working goes against the OP requirement of something simple and quick to get up and running.

Why didn’t you spend that energy constructively helping Simon instead of destructively telling me I’m “wrong”?

Go and help him. If you don’t like my suggestion feel free too BUZZ ORFFF! 🐝

I did help him, i give him a simple way to install something that would work out of the box a few posts ago.

excellent. Take care
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf