#include "std_lib_facilities.h"
int main() // C++ programs start by executing the function main
{
cout << "Hello, World!\n"; // output “Hello, World!”
keep_window_open(); // wait for a character to be entered
return 0;
}
https://code.visualstudio.com/docs/languages/cpp
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.
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.1. you don't want an IDE unless you know precisely why you want it for a particular task. using an IDE is a separate skill in itself. it needs its own learning course which wastes precious time, especially when you're a beginner. first learn to write programs, then learn to use an IDE, one of many, if you need it.
$ cat > example.cxx
#include <iostream>
int main() // C++ programs start by executing the function main
{
std::cout << "Hello, World!\n"; // output “Hello, World!”
return 0;
}
$ g++ example.cxx -o example
$ ./example
Hello, World!
Yes that particular page is useless and I can't work out if they are talking about VS or VSC, it's a joke!
You forgot "apt install g++" :-) Or yum or whatever your non-Debian based distro uses. But use Debian-based (Ubuntu etc) if you want an easy life. That includes people saddled with Windows, if they install WSL.
But I agree with you. IDEs are for when you're dealing with some massive, hundreds of thousands of lines, corporate monstrosity of a code base. If then. Absolutely not needed and really just gets in the way for anything you write yourself.
You forgot "apt install g++" :-)Correct. That would make a tiny bit of a homework to google for the error message in case g++ is not installed. Even that will not be required in a standard Ubuntu installation that has the "command-not-found" package installed by default which makes your shell suggest packages that contain the command that wasn't found but can be installed.
WSL.That's correct. But using a real Linux installation is just so much better, if you have a choice (i.e., are not restricted by corporate policies and do not need to run some windows-specific software that fails to run under Wine).
You forgot "apt install g++" :-) Or yum or whatever your non-Debian based distro uses. But use Debian-based (Ubuntu etc) if you want an easy life. That includes people saddled with Windows, if they install WSL.
But I agree with you. IDEs are for when you're dealing with some massive, hundreds of thousands of lines, corporate monstrosity of a code base. If then. Absolutely not needed and really just gets in the way for anything you write yourself.
Except as soon as you want to do something nontrivial, you will need to learn about makefiles, and then perhaps compiler options, and after that probably git, and before you know it you will be deep in the mire.
Anyone who tells you that programming is simple is being economical with the truth.
Except as soon as you want to do something nontrivial, you will need to learn about makefiles, and then perhaps compiler options, and after that probably git, and before you know it you will be deep in the mire.Makefiles are actually next to trivial and very easy to learn. More complex build systems such as autoconf, cmake, etc. are more difficult, but they are not required until the project gets big and/or aims to be cross-platform compatible and become public.
Anyone who tells you that programming is simple is being economical with the truth.Couldn't be said better.
I just tried to see if C++ worked also (I didn't explicitly install C++). I first tried your example, and it barfed on finding std_lib_facilites.h.
that's the problem. I can't "drop" a compiler in. what is the difference between VSC and VS? anythings else that makes sence? I take it codeblock is not that horrible thing microchip use for MPLABX?
All i want to do is run:Code: [Select]#include "std_lib_facilities.h"
int main() // C++ programs start by executing the function main
{
cout << "Hello, World!\n"; // output “Hello, World!”
keep_window_open(); // wait for a character to be entered
return 0;
}
I have spent the evening getting no where.
So its 13 months later and you haven't made any significant progress!
https://www.eevblog.com/forum/programming/general-ide-to-learn-c-on/ (https://www.eevblog.com/forum/programming/general-ide-to-learn-c-on/)
We suggested several combinations of IDE and (usually) GCC based compilers which would give you less hassle and significantly smaller download size than anything recent from Microsoft. and discussed how to install them. I even posted a zipped project of the "Hello World" program from chapter two of your book, that will work if you use the Bloodshed/Orwell/Embarcardo forks of the Dev-C++ IDE (or with any GCC based compiler from the command line).
I write programs just fine for micro controllers in microchip studio, now I just want to run the examples and exercises in a book to learn C++ that I will use on a micro controller in microchip studio the whole universe blows up |O
I just need to do the stuff in the book, at the end of the day I don't seem to have a choice of IDE , as everyone here points out they are hard work, so I'll be using whatever the micro controller manufacturer provides.
I just need to do the stuff in the book, at the end of the day I don't seem to have a choice of IDE , as everyone here points out they are hard work, so I'll be using whatever the micro controller manufacturer provides.So grab the Embarcardo fork of Dev-C++ (https://www.embarcadero.com/free-tools/dev-cpp) which comes with a reasonably current GCC compiler, and grab the book-specific header file "std_lib_facilities.h" Brucehoult linked above, and have at it with the chapter two "hello World" example. It should 'just work' - as it did for me 13 months ago.
Correct, thought I was going round in the same circle again. I'm also not that interested in the IDE, but the discussion if I recall descended into which IDE is better and I just got lost. I just need to do the stuff in the book, at the end of the day I don't seem to have a choice of IDE , as everyone here points out they are hard work, so I'll be using whatever the micro controller manufacturer provides.
Another point: there is a possibility that you don't need C++. Don't try to lift more weight than you need. Start with plain C.
I never thought it would be this hard. Yes i did try listening over a year ago, I did try stuff and I just gave up as I did not have time to make the whole IDE thing work. Now I try again I still find it is so ridiculous that I have in trying to download a C++ compiler run into a scam website and in trying to download GCC I have gone around and around in circles ending in directory views of a bunch of files on some server and no clue which I am to download.
trying to download GCCthis is what you don't need to do in its native ecosystem. "apt-get install gcc g++" is a single command that will take care of downloading and installing it the right way.
this is what you don't need to do in its native ecosystem. "apt-get install gcc g++" is a single command that will take care of downloading and installing it the right way.
but even under windows, if you use WSL (https://ubuntu.com/wsl), it's going to be just as simple, as far as I understand (never personally used it though -- I use native linux).
But Simon is not on Linux, so talking about Linux is just a waste of time.it's up to him to choose between using a right tool for the job and trying to draw a nail with a silicone dildo. (of course, which of the proposed solutions is meant by each of these analogies depends on everyone's personal views.)
Not meaning to be harsh, but if one cannot even manage to find, install and use basic tools for compiling a couple lines of C++, not sure what will come out of all this.
:popcorn:
As for me making hard work of it, what seems to be the official wiki of codeblocks contains dead links and links to sites that have since changed, not to mention one that tried to scam me into a subscription for mcfee!!!
I need some sort of IDE? or shall I do it all in DOS like the 80's?
Maybe I just start looking at some random tutorials on the web, stuff this old bloke and his book and I just throw it onto an ARM core with microchip studio like I did with C. Will take 10 times longer maybe but looks like my next step is to actually move to linux which I would love to do but that means I have even more stupid situations with "problems" than I am here with my main OS
I had to try. visual studio community on google, hit first Microsoft link, download and run installer, select c++, wait for 2.4GB download, run visual studio, select new project from template, C++ console program (default hello world), ctrl-F5 to build and debug (it says so in the comments), and it prints "hello world"Well done.
probably less than a minute excluded waiting for the download ...
Another point: there is a possibility that you don't need C++. Don't try to lift more weight than you need. Start with plain C.That's a good point, quite a few microcontrollers IDE's just use C.
My dilemma is the same as when I started with C, every book just talks about the language, makes an IDE sound like a simple tool that you "just" use and tells you how to write programs that will only work on a PC as they always involve keyboard input and display output, the very two things that a micro controller does not "just" have. After a lot of head banging I managed to figure out the manufacturers own IDE, learn some C and how the micro controller worked and slowly got there. I could not do a sodding damn thing on a PC with C and neither do I want to. I now start all this again just to have a little look at C++ just to see if it is worth it. Back in the day I did in fact do the C examples in a windows IDE, how cool was that!!!
Is that a simple enough explanation?
The world has changed. The new cool is to remote into numerous boards from your favourite DE, and that, essentially, is the keyboard in/display out, during development.
And much, much more. If you can setup GDB, you get a rich devel env that some of us could only dream about once upon a time.
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.
The world has changed. The new cool is to remote into numerous boards from your favourite DE, and that, essentially, is the keyboard in/display out, during development.
And much, much more. If you can setup GDB, you get a rich devel env that some of us could only dream about once upon a time.
I have not done embedded work, but I would imagine you also get an emulator to check things out on the desktop before going to the real hardware?
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.
I could try visual studio now that I have it, as for not listening I have had a half dozen recommendations and not actually wasted a day on this so have not had time to get through them. The online thing failed, codeblocks seems a waste of time, GNU GCC go use linux as for VS no it is not 2.4GB is is 14GB!!! or did I pick a different option that was equally obviously "the C++ thing" ?
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++.
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.
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++.
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 (https://www.embarcadero.com/products/cbuilder/starter)
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?
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?
Oh, and yes I did try VS, still failed.
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.
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.
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++
Simon, try nano and g++
What a troll >:D
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".
cat >hello.cpp <<END
#include <stdio>
int main(){std::cout << "Hello!\n"; return 0;}
END
g++ hello.cpp -o hello
./hello
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.
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! 🐝
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.
Windows 10 version 2004
excellent. Take care
excellent. Take care
Sorry I called you a troll.
we don’t call people with different views “trolls” in real life.
we don’t call people with different views “trolls” in real life.
you're not listening to radio, or looking at social media much then :scared:
I would actually agree with you, to set up a VM and nano / g++ from the command line, if that didn't mean that you have to know how to install a linux distro (which, again, is surprisingly easy these days, you just read and accept the defaults.)
But why do that when you can go to onlinegdb and do the same thing? It's just textbook exercises
Now that i think of it, you are probably accused of being a troll because you dare suggesting nano instead of VIM (screw that, nano rules)