Compilierproblem mit g++

Maxii

Mitglied
Hallo!

Ich weiß nicht, ob ich zu blöd bin. Das letzte mal habe ich mit C++ vor 4 Jahren unter VC6.0 gearbeitet. Jetzt soll ich für die Uni g++ verwenden. Ich dacht mir, dass da nicht so ein Unterschied sein sollte, aber scheinbar doch.

Hier mal mein Programmcode:
Code:
#include <iostream>

using namespace std;

int main()
{
	cout << "horst\n";
	return 0;
}

Der Aufruf zum Compilieren:

Code:
g++ -c -Wall -ansi test.cpp

und dann der Aufruf zum Linken:

Code:
gcc -o test test.o

und das Resultat:

Code:
test.o: In function `__static_initialization_and_destruction_0(int, int)':
test.cpp:(.text+0x23): undefined reference to `std::ios_base::Init::Init()'
test.o: In function `__tcf_0':
test.cpp:(.text+0x66): undefined reference to `std::ios_base::Init::~Init()'
test.o: In function `main':
test.cpp:(.text+0x76): undefined reference to `std::cout'
test.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*)'
test.o:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status

Ich hoffe, dass das Problem nicht so schwerwiegend ist und eine kleine Änderung mein Leiden mindert :-)

lg Markus
 
Zurück