Hello world in linux

Status
Niet open voor verdere reacties.

arno1991

Gebruiker
Lid geworden
7 aug 2005
Berichten
151
hallo,

ik probeer nu al een tijdje een tekstbericht "Hello World" op het terminal-venster te krijgen, zonder succes. Ik had de code uit een boek "C++ zonder stress" maar daget heeft al het grootste deel aangepast (dank u!). Dit is de code nu:

#include <iostream>

using namespace std;

int main() {
cout << "Hello World\n";

return 0;
}

Dit tik ik nu in de terminal:

$ cd /home/arno1991/c++

en daarna dit (vet) met de eerste lijnen van de foutmelding (dit is 1/6 ong. van het geheel)

arno1991@ubuntu:~$ g++ -I /usr/include helloworld.cpp helloworld
g++: helloworld.cpp: Onbekend bestand of map
g++: helloworld: Onbekend bestand of map
g++: geen invoerbestanden
arno1991@ubuntu:~$ cd /home/arno1991/c++
arno1991@ubuntu:~/c++$ g++ -I /usr/include helloworld.cpp helloworld
g++: helloworld: Onbekend bestand of map
In bestand ingevoegd door /usr/include/c++/4.0.2/i486-linux-gnu/bits/c++config.h:35,
door /usr/include/c++/4.0.2/iostream:43,
door helloworld.cpp:1:
/usr/include/c++/4.0.2/i486-linux-gnu/bits/os_defines.h:39:22: fout: features.h: Onbekend bestand of map
In bestand ingevoegd door /usr/include/c++/4.0.2/i486-linux-gnu/bits/c++locale.h:41,
door /usr/include/c++/4.0.2/iosfwd:45,
door /usr/include/c++/4.0.2/ios:43,
door /usr/include/c++/4.0.2/ostream:44,
door /usr/include/c++/4.0.2/iostream:44,
door helloworld.cpp:1:
/usr/include/c++/4.0.2/cstring:51:20: fout: string.h: Onbekend bestand of map
In bestand ingevoegd door /usr/include/c++/4.0.2/i486-linux-gnu/bits/c++locale.h:42,
door /usr/include/c++/4.0.2/iosfwd:45,
door /usr/include/c++/4.0.2/ios:43,
door /usr/include/c++/4.0.2/ostream:44,
door /usr/include/c++/4.0.2/iostream:44,
door helloworld.cpp:1:
/usr/include/c++/4.0.2/cstdio:52:19: fout: stdio.h: Onbekend bestand of map
In bestand ingevoegd door /usr/include/c++/4.0.2/i486-linux-gnu/bits/c++locale.h:43,
door /usr/include/c++/4.0.2/iosfwd:45,
door /usr/include/c++/4.0.2/ios:43,
door /usr/include/c++/4.0.2/ostream:44,
door /usr/include/c++/4.0.2/iostream:44,
door helloworld.cpp:1:
/usr/include/c++/4.0.2/clocale:49:20: fout: locale.h: Onbekend bestand of map
In bestand ingevoegd door /usr/include/c++/4.0.2/iosfwd:45,
door /usr/include/c++/4.0.2/ios:43,
door /usr/include/c++/4.0.2/ostream:44,
door /usr/include/c++/4.0.2/iostream:44,
door helloworld.cpp:1:
/usr/include/c++/4.0.2/i486-linux-gnu/bits/c++locale.h:44:38: fout: langinfo.h: Onbekend bestand of map
/usr/include/c++/4.0.2/i486-linux-gnu/bits/c++locale.h:45:56: fout: iconv.h: Onbekend bestand of map
/usr/include/c++/4.0.2/i486-linux-gnu/bits/c++locale.h:46:39: fout: libintl.h: Onbekend bestand of map
In bestand ingevoegd door /usr/include/c++/4.0.2/i486-linux-gnu/bits/gthr.h:114, door /usr/include/c++/4.0.2/i486-linux-gnu/bits/c++io.h:37,
door /usr/include/c++/4.0.2/iosfwd:46,
door /usr/include/c++/4.0.2/ios:43,
door /usr/include/c++/4.0.2/ostream:44,
door /usr/include/c++/4.0.2/iostream:44,
door helloworld.cpp:1:
/usr/include/c++/4.0.2/i486-linux-gnu/bits/gthr-default.h:43:21: fout: pthread.h: Onbekend bestand of map
/usr/include/c++/4.0.2/i486-linux-gnu/bits/gthr-default.h:44:20: fout: unistd.h: Onbekend bestand of map
In bestand ingevoegd door /usr/include/c++/4.0.2/iosfwd:47,
door /usr/include/c++/4.0.2/ios:43,
door /usr/include/c++/4.0.2/ostream:44,
door /usr/include/c++/4.0.2/iostream:44,
door helloworld.cpp:1:
/usr/include/c++/4.0.2/cctype:49:19: fout: ctype.h: Onbekend bestand of map
In bestand ingevoegd door /usr/include/c++/4.0.2/cwchar:51,
door /usr/include/c++/4.0.2/bits/postypes.h:46,
door /usr/include/c++/4.0.2/iosfwd:49,
door /usr/include/c++/4.0.2/ios:43,
door /usr/include/c++/4.0.2/ostream:44,
door /usr/include/c++/4.0.2/iostream:44,
door helloworld.cpp:1:

ik gebruik Ubuntu linux 5.10 Breezy badger (gebaseerd op Debian)

hopelijk kan je me helpen,

arno
 
Hallo Arno,

Zoals belooft kijk ik weer met je mee. Ik zie dat ik wat vergeten ben.

De compilatie aanroep mist een -o voor de naam van je applicatie:
g++ -I /usr/include helloworld.cpp -o helloworld

Net getest & werkend bevonden op een linux bak.

Groet van Daget

ps. ik herken de frustratie als je de basis niet meteen draaiend hebt, maar als het eenmaal werkt kun je het echt overal toepassen.
 
ok, bedankt dat je nog wil meekijken!
helaas is hier het resultaat:

arno1991@ubuntu:~$ cd /home/arno1991/c++
arno1991@ubuntu:~/c++$ g++ -I /usr/include helloworld.cpp -o helloworld
In bestand ingevoegd door /usr/include/c++/4.0.2/i486-linux-gnu/bits/c++config.h:35,
door /usr/include/c++/4.0.2/iostream:43,
door helloworld.cpp:1:
/usr/include/c++/4.0.2/i486-linux-gnu/bits/os_defines.h:39:22: fout: features.h: Onbekend bestand of map
In bestand ingevoegd door /usr/include/c++/4.0.2/i486-linux-gnu/bits/c++locale.h:41,
door /usr/include/c++/4.0.2/iosfwd:45,
door /usr/include/c++/4.0.2/ios:43,
door /usr/include/c++/4.0.2/ostream:44,
door /usr/include/c++/4.0.2/iostream:44,
door helloworld.cpp:1:
/usr/include/c++/4.0.2/cstring:51:20: fout: string.h: Onbekend bestand of map
In bestand ingevoegd door /usr/include/c++/4.0.2/i486-linux-gnu/bits/c++locale.h:42,
door /usr/include/c++/4.0.2/iosfwd:45,
door /usr/include/c++/4.0.2/ios:43,
door /usr/include/c++/4.0.2/ostream:44,
door /usr/include/c++/4.0.2/iostream:44,
door helloworld.cpp:1:
/usr/include/c++/4.0.2/cstdio:52:19: fout: stdio.h: Onbekend bestand of map
In bestand ingevoegd door /usr/include/c++/4.0.2/i486-linux-gnu/bits/c++locale.h:43,
door /usr/include/c++/4.0.2/iosfwd:45,
door /usr/include/c++/4.0.2/ios:43,
door /usr/include/c++/4.0.2/ostream:44,
door /usr/include/c++/4.0.2/iostream:44,
door helloworld.cpp:1:
/usr/include/c++/4.0.2/clocale:49:20: fout: locale.h: Onbekend bestand of map
In bestand ingevoegd door /usr/include/c++/4.0.2/iosfwd:45,
door /usr/include/c++/4.0.2/ios:43,
door /usr/include/c++/4.0.2/ostream:44,
door /usr/include/c++/4.0.2/iostream:44,
door helloworld.cpp:1:
/usr/include/c++/4.0.2/i486-linux-gnu/bits/c++locale.h:44:38: fout: langinfo.h: Onbekend bestand of map
/usr/include/c++/4.0.2/i486-linux-gnu/bits/c++locale.h:45:56: fout: iconv.h: Onbekend bestand of map
/usr/include/c++/4.0.2/i486-linux-gnu/bits/c++locale.h:46:39: fout: libintl.h: Onbekend bestand of map
In bestand ingevoegd door /usr/include/c++/4.0.2/i486-linux-gnu/bits/gthr.h:114, door /usr/include/c++/4.0.2/i486-linux-gnu/bits/c++io.h:37,
door /usr/include/c++/4.0.2/iosfwd:46,
door /usr/include/c++/4.0.2/ios:43,
door /usr/include/c++/4.0.2/ostream:44,
door /usr/include/c++/4.0.2/iostream:44,
door helloworld.cpp:1:
/usr/include/c++/4.0.2/i486-linux-gnu/bits/gthr-default.h:43:21: fout: pthread.h: Onbekend bestand of map
/usr/include/c++/4.0.2/i486-linux-gnu/bits/gthr-default.h:44:20: fout: unistd.h: Onbekend bestand of map
In bestand ingevoegd door /usr/include/c++/4.0.2/iosfwd:47,
door /usr/include/c++/4.0.2/ios:43,
door /usr/include/c++/4.0.2/ostream:44,
door /usr/include/c++/4.0.2/iostream:44,
door helloworld.cpp:1:
/usr/include/c++/4.0.2/cctype:49:19: fout: ctype.h: Onbekend bestand of map
In bestand ingevoegd door /usr/include/c++/4.0.2/cwchar:51,
door /usr/include/c++/4.0.2/bits/postypes.h:46,
door /usr/include/c++/4.0.2/iosfwd:49,
door /usr/include/c++/4.0.2/ios:43,
door /usr/include/c++/4.0.2/ostream:44,
door /usr/include/c++/4.0.2/iostream:44,
door helloworld.cpp:1:
/usr/include/c++/4.0.2/ctime:51:18: fout: time.h: Onbekend bestand of map
In bestand ingevoegd door /usr/include/c++/4.0.2/bits/postypes.h:46,
door /usr/include/c++/4.0.2/iosfwd:49,
door /usr/include/c++/4.0.2/ios:43,
door /usr/include/c++/4.0.2/ostream:44,
door /usr/include/c++/4.0.2/iostream:44,
door helloworld.cpp:1:
/usr/include/c++/4.0.2/cwchar:54:19: fout: wchar.h: Onbekend bestand of map
In bestand ingevoegd door /usr/include/c++/4.0.2/iosfwd:49,
door /usr/include/c++/4.0.2/ios:43,
door /usr/include/c++/4.0.2/ostream:44,
door /usr/include/c++/4.0.2/iostream:44,
door helloworld.cpp:1:

ik probeer er nog steeds dezelfde code erdoor heen te jagen, zonder succes, zoals je ziet.
 
Aan de code mankeert niks, die werkt immers op deze machine wel. Kun je me de output eens geven van:

find /usr -name features.h

Oftewel: de melding is dat de compiler features.h niet kan vinden en nu wil ik proberen de locatie met de hand te bepalen. (ik doe even de aanname dat je ook niet bekend bent met linux. Als dat wel zo is, dan excuseer...)
 
ik ben inderdaad niet goed in linux qua terminal... maar bedankt voor al je info, maar deze is blijkbaar (voor de helft dan toch) tevergeefs geweest.
Ik verveelde me wat aan mijn bak, en ben dan gaan "spelen" met synaptic, de package-downloader-installer van ubuntu.
Ik ging eens gaan kijken naar cpp, cpp 4.0, g++ enz. En zag daar steeds een vierkantje met sterretje bij staan => packages zijn geinstalleerd maar er is een update beschikbaar. Dit kan normaal niet met mijn pc, want er staat geen internet op.
Ik had al eens geprobeerd 6.06 LTS te installeren, maar dat eindigde als vastloper (steeds weer). Daar zat het probleem: cpp en g++ werkten niet goed omdat de 6.06 versie van ubuntu deze al voor een deel had overschreven.
Ik ben dan maar achter een harde schijfkoeler, nieuwe fans geweest om mijn pc wat sneller te maken en heb meteen Ubuntu 6.06 LTS in de plaats van de 5.10 geinstalleerd! met succes.
G++ werkt nu fantastisch goed. Dusse...
maar toch heel erg bedankt voor alle moeite die je in de zoektocht hebt gestopt!!!
zo zie je maar: linux kan soms rare kuurtjes oplopen...:)

arno
 
Laatst bewerkt:
Ach, ik heb nog wel vreemdere dingen gezien. Zowel met linux als met windows. Maar goed, ik ben blij dat je weer onderweg bent en dat we in ieder geval het meest basale programma draaiend hebben. :)

Rest mij nog je succes te wensen met het vervolg.

Groet van Daget
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan