Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Salve a tutti. Sto cercando di imparare a programmare senza usare un IDE.
Ho appena scaricato e installato Gedit e GCC 4.2.1 come compilatore.
Pero mi sono bloccato in un passaggio.
Ho scritto il codice del classico Hello World in C++ e ho salvato come "hello.cpp" sul Desktop.
Per compilare vado sul terminale, mi sposto sul Desktop e scrivo:
Penso che si riferisca al fatto che non ho i permessi per farlo.
Da premettere che uso Mac OS X, programmo in C++ e di utenti ce ne solo uno, quello amministratore.
Forse ho risolto.
Ho eseguito il comando "su" e ho inserito la password dell'utente e ora quando compilo non mi da più quell'errore.
Me ne da un altro
Apro il terminale, mi metto nella cartella dove ce il file da compilare cioè il Desktop e inserisco il codice:
gcc hello.cpp -o hello
oppure
g++ hello.cpp -o hello
e mi da questo errore in entrambi i casi:
hello.cpp:1:2: error: invalid preprocessing directive #Include
hello.cpp: In function ‘int main()’:
hello.cpp:5: error: ‘cout’ is not a member of ‘std’
Il codice sorgente del file è:
---------------------------------
#Include <iostream>
int main()
{
std::cout << "Ciao, mondo \n";
return 0;
}
---------------------------------
il file si chiama "hello.cpp"
Ho salvato nel Desktop e con il nome "hello.c"
Per compilare uso:
gcc hello.c -o hello
e mi da questo errore:
hello.c:1: error: expected identifier or ‘(’ before ‘{’ token
hello.c:1: error: stray ‘\’ in program
hello.c:1: error: stray ‘\’ in program
hello.c:1: error: stray ‘\’ in program
hello.c:1: error: stray ‘\’ in program
hello.c:1: error: stray ‘\’ in program
hello.c:2: error: stray ‘\’ in program
hello.c:2: error: stray ‘\’ in program
hello.c:2: error: stray ‘\’ in program
hello.c:2: error: stray ‘\’ in program
hello.c:2: error: stray ‘\’ in program
hello.c:2: error: stray ‘\’ in program
hello.c:2: error: stray ‘\’ in program
hello.c:3: error: stray ‘\’ in program
hello.c:3: error: stray ‘\’ in program
hello.c:3: error: stray ‘\’ in program
hello.c:3: error: stray ‘\’ in program
hello.c:4: error: stray ‘\’ in program
hello.c:4: error: stray ‘\’ in program
hello.c:4: error: stray ‘\’ in program
hello.c:4: error: stray ‘\’ in program
hello.c:4: error: stray ‘\’ in program
hello.c:4: error: stray ‘\’ in program
hello.c:4: error: stray ‘\’ in program
hello.c:5: error: stray ‘\’ in program
hello.c:6: error: stray ‘\’ in program
hello.c:6: error: stray ‘\’ in program
hello.c:8: error: stray ‘\’ in program
hello.c:8: error: stray ‘\’ in program
hello.c:8: error: stray ‘\’ in program
hello.c:8: error: stray ‘#’ in program
hello.c:8: error: stray ‘\’ in program
hello.c:8: error: stray ‘\’ in program
hello.c:8: error: stray ‘\’ in program
hello.c:8: error: stray ‘\’ in program
hello.c:13: error: stray ‘\’ in program
hello.c:13: error: stray ‘\’ in program
hello.c:14: error: stray ‘\’ in program
hello.c:14: error: stray ‘\’ in program
hello.c:14:10: warning: backslash-newline at end of file