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.
- 09-02-2010 #1Just 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
- 09-02-2010 #2Just 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?
- 09-02-2010 #3Just Joined!
- Join Date
- Sep 2010
- Posts
- 5
- 09-03-2010 #4Just Joined!
- Join Date
- Aug 2007
- Posts
- 9
- 09-03-2010 #5
- 09-04-2010 #6Just 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
- 09-05-2010 #7
Hm. Could you please do:
You may have an empty or incomplete list of packages; running the update command should solve this.Code:$ sudo apt-get update $ sudo apt-get install build-essential
If doesn't work either, will you please tell us the output of the following:
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.Code:$ cat /etc/apt/sources.list
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.
- 09-05-2010 #8Just 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
- 09-05-2010 #9
- 09-05-2010 #10Just Joined!
- Join Date
- Sep 2010
- Posts
- 6
//HelloWorld.cc
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!" << endl;
return 0;
}


Reply With Quote

