Getting back into C++ with knoppix

  • Context: C/C++ 
  • Thread starter Thread starter julian
  • Start date Start date
  • Tags Tags
    C++
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
11 replies · 5K views
Messages
862
Reaction score
366
Been a long time since I did any C/C++. I have an older version of knoppix which looks like it might have C++.

I'll need some step by step help here - don't know very much. I go to the menu, go to "Development", and there is a "KDevelop: C/C++ (IDE for C/C++)". Should I click on this or something else?
 
Physics news on Phys.org
KDevelop is the graphical IDE for the GNU Compiler Collection - so that's what you want, yep.
http://kdevelop.org/

The c/c++ compiler is called gcc and can be called from the commandline.
You should probably update your distro though ... it will have the latest compiler and IDEs.
Some parts of the older gcc versions are no longer supported in the newer ones.

The knoppix forums have specific help on using the distro and it's bits.
 
So I've clicked on it. Should I now click on "File", "new"? It asks for a file name - do I have to write like name.something ? Sorry I really know nothing.
 
In UNIX everything is files. The IDE will let you open an existing file or you can start a new project which will have it's own file and thus a filename. So yeah - you have to type one in - name your program. Have you used any Unix-type software before?

I've never used an IDE in my life, and it sounds like you havn't either.
You may be happier with a text editor and a terminal ... how did you program before?

There will be user documentation someplace - in a terminal, type "man kdevelop" or "info kdevelop" for clues ... or use the kdevelop link above.
 
julian said:
So I've clicked on it. Should I now click on "File", "new"? It asks for a file name - do I have to write like name.something ? Sorry I really know nothing.

I suggest to have a look at http://www.learncpp.com/.
 
  • Like
Likes   Reactions: 1 person
Simon Bridge said:
In UNIX everything is files. The IDE will let you open an existing file or you can start a new project which will have it's own file and thus a filename. So yeah - you have to type one in - name your program. Have you used any Unix-type software before?

I've never used an IDE in my life, and it sounds like you havn't either.
You may be happier with a text editor and a terminal ... how did you program before?

There will be user documentation someplace - in a terminal, type "man kdevelop" or "info kdevelop" for clues ... or use the kdevelop link above.

I've used UNIX to do latex but that's all.

I got up a kDevelop window, I named a file called "pop". Typed in a sample programme.

I clicked on "Konsole" and a narrow window came up at the bottom. I tried typing in "g++ pop" and "gcc pop" and "c++ pop" to try to compile the programme but every times got the message
"pop: file not recognized: File format not recognized
collect2: ld returned 1 exit status"
 
I don't think someone who's new to c/c++ is going to use a text editor like vi or emacs better to start with pico, make sure your using the right directory structure when compling your programs, you'll usually be put in etc/home so try ./file_name in the directory your using. also I haven't tried programming in unix in a while but I thought it was cc filename flags, that may be out of order, check the docs.
 
Last edited:
thankz said:
I don't think someone who's new to c/c++ is going to use a text editor...
julian (OP) is not new to C/C++ - it's just been "a long time since [he] did any C/C++", so he's probably a bit rusty.

Everyone has a favorite text editor... I'd prefer to know how julian recalls programming from way back when, before suggesting something. You never know, he may be an old emacs hacker, or one of the original "ed" devs... iirc the default on knoppix is kwrite or kate - one of the KDE editors. They are usually pretty easy to use and one can try different one later.

Most people program in an IDE these days and it's pretty much de-rigeur for anything object oriented.
So getting used to the IDE is probably best advise here.

That will mean following a tutorial from online.
 
Simon Bridge said:
Most people program in an IDE these days and it's pretty much de-rigeur for anything object oriented.
So getting used to the IDE is probably best advise here.
Personally, I can't stand most IDEs. They get in my way more than they help. That's my opinion; others have rather different opinions.


julian said:
I've used UNIX to do latex but that's all.

I got up a kDevelop window, I named a file called "pop". Typed in a sample programme.

I clicked on "Konsole" and a narrow window came up at the bottom. I tried typing in "g++ pop" and "gcc pop" and "c++ pop" to try to compile the programme but every times got the message
"pop: file not recognized: File format not recognized
collect2: ld returned 1 exit status"

You have to somehow let the compiler know the language the file is written in. You didn't do that. There are a couple of approaches. One approach is via the -x option to the compiler. Don't do that. The recommended approach is to use the appropriate file suffix. Name your file pop.c if you wrote a C program; use pop.C, pop.cc, pop.cxx, pop.cpp, or pop.c++ if you wrote a C++ program. You have lots of suffix choices for C++. Pick one and be consistent. I wouldn't use the .C (capital C) suffix, personally. That will get you in trouble on windows or Mac OS.

If you wrote a c++ program you want to use g++ to compile and link it. The gcc command invokes the c++ compiler if gcc recognizes the file as a c++ source file but it does not automatically use the C++ library for linking. You have to manually specify the c++ library on the command line when you use gcc to compile and link your program. Those worries go away if you use g++ instead of gcc.
 
Last edited: