Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Getting back into C++ with knoppix

  1. Jun 6, 2014 #1

    julian

    User Avatar
    Gold Member

    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 - dont 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?
     
  2. jcsd
  3. Jun 6, 2014 #2

    Simon Bridge

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member
    2016 Award

    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.
     
  4. Jun 6, 2014 #3

    julian

    User Avatar
    Gold Member

    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.
     
  5. Jun 6, 2014 #4

    Simon Bridge

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member
    2016 Award

    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.
     
  6. Jun 7, 2014 #5

    fluidistic

    User Avatar
    Gold Member

    I suggest to have a look at http://www.learncpp.com/.
     
  7. Jun 7, 2014 #6

    julian

    User Avatar
    Gold Member

    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"
     
  8. Jun 8, 2014 #7

    Simon Bridge

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member
    2016 Award

    You may be happier with a text editor and a terminal ... how did you program before?
    Have you tried the knoppix help site?
    Have you tried the learn cpp site?
     
  9. Jun 8, 2014 #8
    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: Jun 8, 2014
  10. Jun 8, 2014 #9

    Simon Bridge

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member
    2016 Award

    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.
     
  11. Jun 8, 2014 #10

    D H

    User Avatar
    Staff Emeritus
    Science Advisor

    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.


    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: Jun 8, 2014
  12. Jun 11, 2014 #11

    julian

    User Avatar
    Gold Member

    Thanks all. I'm up and running.
     
  13. Jun 12, 2014 #12

    Simon Bridge

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member
    2016 Award

    Cheers and have fun :)
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Getting back into C++ with knoppix
  1. Get and putchar in c (Replies: 19)

  2. C - getting input (Replies: 3)

Loading...