Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 19
Hi all, I'm relatively new to Linux and programming. I am using Knoppix version 6.2.1 but cannot seem to compile a simple program to add two numbers together. The source ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Sep 2010
    Posts
    6

    Unable to compile using g++


    Hi all,

    I'm relatively new to Linux and programming. I am using Knoppix version 6.2.1 but cannot seem to compile a simple program to add two numbers together. The source code was written in a leafpad document and named "SimpleAdder.cc". I saved this to a directory called ~/c++ . In the terminal I changed to this directory then typed "g++ SimpleAdder.cc -o SimpleAdder". The terminal returned

    "bash: g++: command not found"

    Can anyone help me figure where I went wrong? (I also tried "make SimpleAdder" while in the same directory but only got "make: g++: command not found" and "make: *** [SimpleAdder] Error 127".

    Thanks in advance

  2. #2
    Just Joined!
    Join Date
    Sep 2010
    Posts
    6
    I have just thoughts; maybe the CD version of Knoppix 6.2.1 which I am using doesn't have a C++ compiler?

  3. #3
    Just Joined!
    Join Date
    Sep 2010
    Posts
    5
    Quote Originally Posted by Rudipoo View Post
    I have just thoughts; maybe the CD version of Knoppix 6.2.1 which I am using doesn't have a C++ compiler?
    I seem to be having the same issues...see my thread below yours.

    Maybe we need the dvd version of knoppix.

  4. #4
    Just Joined!
    Join Date
    Aug 2007
    Posts
    9
    Quote Originally Posted by Rudipoo View Post
    Hi all,

    I'm relatively new to Linux and programming. I am using Knoppix version 6.2.1 but cannot seem to compile a simple program to add two numbers together. The source code was written in a leafpad document and named "SimpleAdder.cc". I saved this to a directory called ~/c++ . In the terminal I changed to this directory then typed "g++ SimpleAdder.cc -o SimpleAdder". The terminal returned

    "bash: g++: command not found"

    Can anyone help me figure where I went wrong? (I also tried "make SimpleAdder" while in the same directory but only got "make: g++: command not found" and "make: *** [SimpleAdder] Error 127".

    Thanks in advance
    Seems like you don't have g++ installed. I don't know much about Knoppix, I have tried it briefly some time, but I guess you have some kind of package manager of some kind where you can search for software and install it with a few clicks.

    Best regards

    Johnny Rosenberg

  5. #5
    Linux Newbie unlimitedscolobb's Avatar
    Join Date
    Jan 2008
    Posts
    120
    Quote Originally Posted by Rudipoo View Post
    "bash: g++: command not found"
    Open a terminal window and type the following:

    Code:
      $ sudo apt-get install build-essential
    This will install the essential packages you need to compile basic things, including the GNU C++ compiler g++.

  6. #6
    Just Joined!
    Join Date
    Sep 2010
    Posts
    6
    I'm afraid your hint didn't work unlimitedscolobb; after saying

    Reading package lists... Done
    Building dependancy tree
    Reading state information... Done

    the terminal reads

    E: couldn't find package build-essential

    So, any other suggestions? Is it certain that the cd version has a c++ compiler?

    Thanks

  7. #7
    Linux Newbie unlimitedscolobb's Avatar
    Join Date
    Jan 2008
    Posts
    120
    Quote Originally Posted by Rudipoo View Post
    E: couldn't find package build-essential
    Hm. Could you please do:

    Code:
      $ sudo apt-get update
      $ sudo apt-get install build-essential
    You may have an empty or incomplete list of packages; running the update command should solve this.

    If doesn't work either, will you please tell us the output of the following:

    Code:
      $ cat /etc/apt/sources.list
    This will tell us which repositories is your apt told to fetch packages from. Although I am inclined to find it unlikely, this list may be incomplete or empty.

    Quote Originally Posted by Rudipoo View Post
    Is it certain that the cd version has a c++ compiler?
    Please note that I am not trying out the commands I suggest within a Knoppix LiveCD environment, but I cannot see any reason for a C++ compiler not to be accessible from this environment. I may be wrong, however
    Last edited by unlimitedscolobb; 09-05-2010 at 12:41 PM. Reason: Add explanations.

  8. #8
    Just Joined!
    Join Date
    Sep 2010
    Posts
    6
    Hey, thanks for your help. It was all going great (did the update, then did the build-essential), and everything seemed to be installed correctly. Then I tried a simple HelloWorld program. Here is a sample of the error messages:

    knoppix@Microknoppix:~$ g++ HelloWorld.cc -o HelloWorld
    In file included from /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/cwchar:49,
    from /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/bits/postypes.h:47,
    from /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/iosfwd:47,
    from /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/ios:44,
    from /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/ostream:45,
    from /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/iostream:45,
    from HelloWorld.cc:1:
    /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/cstddef:48:25: error: stddef.h: No such file or directory
    In file included from /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/cwchar:49,
    from /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/bits/postypes.h:47,
    from /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/iosfwd:47,
    from /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/ios:44,
    from /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/ostream:45,
    from /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/iostream:45,
    from HelloWorld.cc:1:
    /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/cstddef:55: error: ':trdiff_t' has not been declared
    /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/cstddef:56: error: '::size_t' has not been declared
    In file included from /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/iosfwd:47,
    from /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/ios:44,
    from /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/ostream:45,
    from /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/iostream:45,
    from HelloWorld.cc:1:
    /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/bits/postypes.h:77: error: 'ptrdiff_t' does not name a type
    In file included from /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/bits/stl_algobase.h:72,
    from /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/bits/char_traits.h:46,
    from /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/ios:46,
    from /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/ostream:45,
    from /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/iostream:45,
    from HelloWorld.cc:1:
    /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/bits/stl_iterator_base_types.h:108: error: expected type-specifier before 'ptrdiff_t'
    /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/bits/stl_iterator_base_types.h:108: error: expected '>' before 'ptrdiff_t'
    /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/bits/stl_iterator_base_types.h:119: error: '_Pointer' does not name a type
    /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/bits/stl_iterator_base_types.h:121: error: '_Reference' does not name a type
    /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/bits/stl_iterator_base_types.h:145: error: 'ptrdiff_t' does not name a type
    /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/bits/stl_iterator_base_types.h:155: error: 'ptrdiff_t' does not name a type
    In file included from /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/bits/stl_algobase.h:74,
    from /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/bits/char_traits.h:46,
    from /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/ios:46,
    from /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/ostream:45,
    from /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/iostream:45,
    from HelloWorld.cc:1:
    /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/bits/stl_iterator.h:100: error: wrong number of template arguments (5, should be 3)
    /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/bits/stl_iterator_base_types.h:110: error: provided for 'template<class _Category, class _Tp, class _Distance> struct std::iterator'
    /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/bits/stl_iterator.h:387: error: wrong number of template arguments (5, should be 3)
    /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/bits/stl_iterator_base_types.h:110: error: provided for 'template<class _Category, class _Tp, class _Distance> struct std::iterator'
    /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/bits/stl_iterator.h:471: error: wrong number of template arguments (5, should be 3)
    /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/bits/stl_iterator_base_types.h:110: error: provided for 'template<class _Category, class _Tp, class _Distance> struct std::iterator'
    /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/bits/stl_iterator.h:558: error: wrong number of template arguments (5, should be 3)
    /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/bits/stl_iterator_base_types.h:110: error: provided for 'template<class _Category, class _Tp, class _Distance> struct std::iterator'
    In file included from /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/bits/char_traits.h:46,
    from /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/ios:46,
    from /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/ostream:45,
    from /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/iostream:45,
    from HelloWorld.cc:1:
    /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/bits/stl_algobase.h: In static member function 'static _Tp* std::__copy_move_backward<_IsMove, true, std::random_access_iterator_tag>::__copy_move_b(co nst _Tp*, const _Tp*, _Tp*)':
    /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/bits/stl_algobase.h:571: error: 'ptrdiff_t' does not name a type
    /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/bits/stl_algobase.h:572: error: '_Num' was not declared in this scope
    In file included from /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/ios:46,
    from /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/ostream:45,
    from /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/iostream:45,
    from HelloWorld.cc:1:
    /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/bits/char_traits.h: At global scope:
    /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/bits/char_traits.h:110: error: 'std::size_t' has not been declared
    /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/bits/char_traits.h:112: error: 'size_t' in namespace 'std' does not name a type
    /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/bits/char_traits.h:116: error: 'std::size_t' has not been declared
    /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/bits/char_traits.h:119: error: 'std::size_t' has not been declared
    /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/bits/char_traits.h:122: error: 'std::size_t' has not been declared
    /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/bits/char_traits.h:125: error: 'std::size_t' has not been declared
    /UNIONFS/usr/bin/../lib/gcc/../../include/c++/4.3/bits/char_traits.h:151: error: 'std::size_t' has not been declared

    Any thoughts? Thanks again

  9. #9
    Linux Newbie unlimitedscolobb's Avatar
    Join Date
    Jan 2008
    Posts
    120
    Quote Originally Posted by Rudipoo View Post
    Then I tried a simple HelloWorld program. Here is a sample of the error messages:
    [...]
    Will you please post the source code of your program here?

  10. #10
    Just Joined!
    Join Date
    Sep 2010
    Posts
    6
    //HelloWorld.cc
    #include <iostream>
    using namespace std;

    int main()
    {
    cout << "Hello World!" << endl;
    return 0;
    }

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •