Herzlich Willkommen, lieber Gast!
  Sie befinden sich hier:

  Forum » C / C++ (ANSI-Standard) » Fehler beim compilieren. iostream?

Forum | Hilfe | Team | Links | Impressum | > Suche < | Mitglieder | Registrieren | Einloggen
  Quicklinks: MSDN-Online || STL || clib Reference Grundlagen || Literatur || E-Books || Zubehör || > F.A.Q. < || Downloads   

Autor Thread - Seiten: > 1 <
000
24.01.2007, 04:47 Uhr
so1eda



Hallo, ich versuche mir in meiner Freizeit mit Hilfe eines Buches etwas C++ beizubringen. Leider habe ich schon mit dem ersten kleinen Programm Probleme.
Beim compilieren unter Linux mit > "gcc Programm1.cpp" erhalte ich für diesen simplen Quellcode:


C++:
#include <iostream>

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



diese Fehlermeldung:

In file included from /usr/include/c++/4.1.2/backward/iostream.h:31,
from /home/Svenne/Desktop/Programm1.cpp:1:
/usr/include/c++/4.1.2/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.
/tmp/ccqcuY0t.o: In function `__static_initialization_and_destruction_0(int, int)':
Programm1.cpp:(.text+0x23): undefined reference to `std::ios_base::Init::Init()'
/tmp/ccqcuY0t.o: In function `__tcf_0':
Programm1.cpp:(.text+0x66): undefined reference to `std::ios_base::Init::~Init()'
/tmp/ccqcuY0t.o: In function `main':
Programm1.cpp:(.text+0x76): undefined reference to `std::cout'
Programm1.cpp:(.text+0x7b): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/tmp/ccqcuY0t.o:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
Svenne@so1fg:~> gcc '/home/Svenne/Desktop/Programm1.cpp'
/home/Svenne/Desktop/Programm1.cpp: In function ‘int main()’:
/home/Svenne/Desktop/Programm1.cpp:5: error: ‘cout’ was not declared in this scope

Ich verstehe zwar nicht viel, aber ich nehme an, dass die Bibliothek "iostream" nicht gefunden wurde und die folgenden Fehler nur die Auswirkung dessen sind.
In dem Buch stand statt "iostream" zwar "iostream.h", aber das habe ich schon abgeändert. Ich erhalte mit beiden Varianten sie selbe Fehlermeldung.

Vielen Dank und mit freundlichen Grüßen
Sven

Dieser Post wurde am 24.01.2007 um 04:48 Uhr von so1eda editiert.
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
001
24.01.2007, 08:05 Uhr
FloSoft
Medialer Over-Flow
(Administrator)


Hi,
also:

du hattest im Buch wahrscheinlich "iostream.h" drinstehen, das ist veraltet (deprecated) daher die erste Warnung. Im Post hast du das .h ja schon weggelassen: Sehr gut!

Ohne .h liegt jedoch cout und Co im namespace std, also entweder


C++:
using namespace std;



oder


C++:
std::cout << ...



Dann musst du natürlich nicht "gcc" nehmen, das ist der C-Compiler (darum die __gxx_personality_v0-Fehlermeldung). Mit g++ sollte es klappen.
--
class God : public ChuckNorris { };
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
002
24.01.2007, 09:10 Uhr
virtual
Sexiest Bit alive
(Operator)


Du solltest mit dem g++ anstelle vom gcc kompilieren.
--
Gruß, virtual
Quote of the Month
Ich eß' nur was ein Gesicht hat (Creme 21)
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
003
24.01.2007, 10:02 Uhr
so1eda



Vielen Dank. Jetzt funktioniert es. Und ich weiß endlich, wie der richtige Compiler heißt...
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
004
24.01.2007, 14:13 Uhr
J-jayz-Z
Perl Crack ala Carte
(Operator)


na ja, g++ und gcc -llibstd++ sind IMHO identisch
--
perl -Mstrict -Mwarnings -e 'package blub; sub new { bless {} } sub bar {my $self=shift; $self->{bla}="66756e2d736f66742e6465"; return $self->{bla};} my $foo=blub->new();print "Hallo ";print pack("H*",$foo->bar()); print "\n"'
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
Seiten: > 1 <     [ C / C++ (ANSI-Standard) ]  


ThWBoard 2.73 FloSoft-Edition
© by Paul Baecher & Felix Gonschorek (www.thwboard.de)

Anpassungen des Forums
© by Flo-Soft (www.flo-soft.de)

Sie sind Besucher: