webForumDet fria alternativet

hello world, i linux

3 svar · 433 visningar · startad av bughawk

bughawkMedlem sedan juni 20001 839 inlägg
#1

yrin@c213~/hacking/div-tester>more test.cpp
#include <iostream>

using namespace std;

void main (void)
{
cout << "test" << endl;
}

yrin@c213~/hacking/div-tester>gcc -o test test.cpp
/tmp/cctwVlbh.o: In function `main':
/tmp/cctwVlbh.o(.text+0x4): undefined reference to `endl(ostream &)'
/tmp/cctwVlbh.o(.text+0xe): undefined reference to `cout'
/tmp/cctwVlbh.o(.text+0x13): undefined reference to `ostream::operator<<(char const *)'
/tmp/cctwVlbh.o(.text+0x1e): undefined reference to `ostream::operator<<(ostream &(*)(ostream &))'
collect2: ld returned 1 exit status
yrin@c213~/hacking/div-tester>

..Och varför vill inte detta fungera ? :l

bughawkMedlem sedan juni 20001 839 inlägg
#2

En kompis kom på lösningen..

Måste förstås använda "g++", inte "gcc".. ;)

SweyMedlem sedan apr. 20003 971 inlägg
#3

Bra att det löste sig. Säg till när du gjort ditt första riktiga Linux-prog så får vi se hur det blev ;)

------------------
- Swey
Glömde jag säga snälla?

bughawkMedlem sedan juni 20001 839 inlägg
#4

Jag borde nog börja med att port:a alla möjliga småprylar som jag har hållit på med... :)

Och så måste jag lära mig linux-api:et...

126 ms totalt · 3 externa anrop · v20260731065814-full.30151723
0 ms — hämta forumlista (cache)
0 ms — hämta statistik (cache)
124 ms — hämta tråd, inlägg och bilagor (db)