|
|
|
![]() |
|
Strumenti |
![]() |
#1 |
Senior Member
Iscritto dal: Nov 2002
Città: Torino
Messaggi: 601
|
problema a compilare "ciao mondo"
Salve,
stavo provando a compilare il classico "ciao mondo" in C. Non mi apettavo nessun problema, ma la shell mi vomita addosso questa brutta roba quando lancio gcc primo.c. Qualcuno sa cosa e' successo? La distro e' una debian sid, gcc3.3.1 In file included from primo.c:3: /usr/lib/gcc-lib/i386-linux/3.3.1/include/stdio.h:37:23: features.h: No such file or directory In file included from /usr/lib/gcc-lib/i386-linux/3.3.1/include/stdio.h:43, from primo.c:3:/usr/lib/gcc-lib/i386-linux/3.3.1/include/stddef.h:213: error: syntax error before "typedef" /usr/lib/gcc-lib/i386-linux/3.3.1/include/stdio.h:45:25: bits/types.h: No such file or directory |
![]() |
![]() |
![]() |
#2 | |
Senior Member
Iscritto dal: Sep 2000
Città: lodi-crema-milano.
Messaggi: 12333
|
Re: problema a compilare "ciao mondo"
Quote:
potresti provare a mettere qua il listato del programma? il sorgente insomma? io avevo provato a scriverlo e funzionava perfettamente (ettecredo son 10 righe di codice ![]() ciao!
__________________
La teoria è quando si sa tutto e niente funziona. La pratica è quando tutto funziona e nessuno sa il perché. Noi abbiamo messo insieme la teoria e la pratica: non c'è niente che funzioni... e nessuno sa il perché! |
|
![]() |
![]() |
![]() |
#3 |
Senior Member
Iscritto dal: Nov 2002
Città: Torino
Messaggi: 601
|
Codice:
/* Primo programma in C */ #include<stdio.h> main() { printf("ciao mondo\n"); return 0; } |
![]() |
![]() |
![]() |
#4 | |
Senior Member
Iscritto dal: Sep 2000
Città: lodi-crema-milano.
Messaggi: 12333
|
Quote:
int main(void) e prova ![]() da quanto mi ricordo, devi mettere "int" per dirgli che la funzione (main) restituisce un valore intero (return 0). void invece serve per dire al compilatore che la main non richiede parametri. poi se si può scrivere solo main() invece che int main(void), questo non lo so...
__________________
La teoria è quando si sa tutto e niente funziona. La pratica è quando tutto funziona e nessuno sa il perché. Noi abbiamo messo insieme la teoria e la pratica: non c'è niente che funzioni... e nessuno sa il perché! |
|
![]() |
![]() |
![]() |
#5 |
Senior Member
Iscritto dal: Oct 2001
Città: Firenze
Messaggi: 585
|
Forse ci vorrebbe uno spazio dopo "#include" , no?
|
![]() |
![]() |
![]() |
#6 |
Senior Member
Iscritto dal: Nov 2002
Città: Torino
Messaggi: 601
|
ho provato tutte e due ma continua a darmi gli stessi errori
![]() ![]() |
![]() |
![]() |
![]() |
#7 |
Senior Member
Iscritto dal: Oct 2001
Messaggi: 11471
|
strano da me funziona.
hai installato le glibc-dev ? |
![]() |
![]() |
![]() |
#8 |
Senior Member
Iscritto dal: May 2003
Città: Un mondo che non c'è.
Messaggi: 1731
|
Io ho fatto cosi e va :
Codice:
#include <stdio.h> void main() { printf("Ciao mondo\n"); } gcc prova.c -o prova
__________________
[17:13] <ANOnimoVeneziano> Devo dire che Windows mi ha salvato la vita. ![]() ![]() |
![]() |
![]() |
![]() |
#9 |
Senior Member
Iscritto dal: Oct 2002
Città: bologna
Messaggi: 541
|
non credo sia corretto nel main un return(0), semmai exit(0)... e poi dopo include ci va lo spazio...
|
![]() |
![]() |
![]() |
#10 |
Senior Member
Iscritto dal: Nov 2002
Città: Torino
Messaggi: 601
|
Regola dello pseudo-niubbo-programmatore:
prima di compilare un programma e rompere le palle ai ragazzi del forum di hwupgrade, assicurati di avere installate le librerie. |
![]() |
![]() |
![]() |
#11 |
Senior Member
Iscritto dal: Feb 2001
Città: Foggia
Messaggi: 2519
|
![]() ![]() ![]() ![]() dai, no problem ![]()
__________________
mi sembra di essere tornato adolescente ai bei tempi.. che figata essere di nuovo su questo forum ![]() |
![]() |
![]() |
![]() |
#12 |
Senior Member
Iscritto dal: Apr 2003
Messaggi: 828
|
prova a lasciare una riga vuota dopo la parentesi graffa finale.
Invece di return 0 prova a mettere: system("PAUSE"); dopo dimmi ciao!
__________________
----LukA4e---- www.foxlinux.org |
![]() |
![]() |
![]() |
#13 | |
Senior Member
Iscritto dal: Jul 1999
Città: Torino
Messaggi: 2221
|
Quote:
![]() |
|
![]() |
![]() |
![]() |
#14 |
Senior Member
Iscritto dal: Apr 2003
Messaggi: 828
|
skusa non avevo letto tt le risposte.
Ciao!!
__________________
----LukA4e---- www.foxlinux.org |
![]() |
![]() |
![]() |
#15 |
Bannato
Iscritto dal: Mar 2003
Messaggi: 105
|
dove si trova il pacchetto delle glibc-dev su slackware 9 ??
ho il suo stesso problema, ma in usr/include è pieno di librerie! ci sono le gtk-1.2/gtk/gtk.h e le gtk-2.0/gtk/gtk.h Ho provato a compilare questo ma non mi trova le librerie! #include <gtk/gtk.h> /* This is a callback function. The data arguments are ignored * in this example. More on callbacks below. */ static void hello( GtkWidget *widget, gpointer data ) { g_print ("Hello World\n"); } static gboolean delete_event( GtkWidget *widget, GdkEvent *event, gpointer data ) { /* If you return FALSE in the "delete_event" signal handler, * GTK will emit the "destroy" signal. Returning TRUE means * you don't want the window to be destroyed. * This is useful for popping up 'are you sure you want to quit?' * type dialogs. */ g_print ("delete event occurred\n"); /* Change TRUE to FALSE and the main window will be destroyed with * a "delete_event". */ return TRUE; } /* Another callback */ static void destroy( GtkWidget *widget, gpointer data ) { gtk_main_quit (); } int main( int argc, char *argv[] ) { /* GtkWidget is the storage type for widgets */ GtkWidget *window; GtkWidget *button; /* This is called in all GTK applications. Arguments are parsed * from the command line and are returned to the application. */ gtk_init (&argc, &argv); /* create a new window */ window = gtk_window_new (GTK_WINDOW_TOPLEVEL); /* When the window is given the "delete_event" signal (this is given * by the window manager, usually by the "close" option, or on the * titlebar), we ask it to call the delete_event () function * as defined above. The data passed to the callback * function is NULL and is ignored in the callback function. */ g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (delete_event), NULL); /* Here we connect the "destroy" event to a signal handler. * This event occurs when we call gtk_widget_destroy() on the window, * or if we return FALSE in the "delete_event" callback. */ g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (destroy), NULL); /* Sets the border width of the window. */ gtk_container_set_border_width (GTK_CONTAINER (window), 10); /* Creates a new button with the label "Hello World". */ button = gtk_button_new_with_label ("Hello World"); /* When the button receives the "clicked" signal, it will call the * function hello() passing it NULL as its argument. The hello() * function is defined above. */ g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (hello), NULL); /* This will cause the window to be destroyed by calling * gtk_widget_destroy(window) when "clicked". Again, the destroy * signal could come from here, or the window manager. */ g_signal_connect_swapped (G_OBJECT (button), "clicked", G_CALLBACK (gtk_widget_destroy), G_OBJECT (window)); /* This packs the button into the window (a gtk container). */ gtk_container_add (GTK_CONTAINER (window), button); /* The final step is to display this newly created widget. */ gtk_widget_show (button); /* and the window */ gtk_widget_show (window); /* All GTK applications must have a gtk_main(). Control ends here * and waits for an event to occur (like a key press or * mouse event). */ gtk_main (); return 0; } |
![]() |
![]() |
![]() |
#16 |
Bannato
Iscritto dal: Mar 2003
Messaggi: 105
|
i programmi compilano perfettamente, l'unica copsa è che non mi trova le gtk, e se nell'include gli metto il percorso reale di gtk.h poi mi da errore per tutti gli include con percorso errato che ci sono in gtk.h!!!!!!!!!!!1
COME GLI DICO DI PARTIRE A CERCARE DIRETTAMENTE DA /USR/INCLUDE/GTK-1.2 OLTRE CHE DA /USR/INCLUDE E BASTA? DEVO FARE QUALCHE EXPORT ? |
![]() |
![]() |
![]() |
#17 |
Senior Member
Iscritto dal: Jun 2002
Città: Roma
Messaggi: 517
|
Ciao
anch'io ho avuto qualche problema a compilare dei programmi per Gnome 1 ... il fatto è che con il passaggio a Gnome 2 alcune librerie accessorie a gtk1.2 non sono state incluse; Da qualche parte, non mi ricordo se su questo o un altro forum, ho scoperto che la soluzione consiste nell'installare un paio di librerie dal repository della slack 8.1; appena lo ritrovo posto i nomi dei pacchetti. |
![]() |
![]() |
![]() |
#18 | |
Senior Member
Iscritto dal: Oct 2001
Messaggi: 11471
|
Quote:
ciao ![]() |
|
![]() |
![]() |
![]() |
#19 |
Bannato
Iscritto dal: Mar 2003
Messaggi: 105
|
ho fatto:
gcc -I/usr/include/gtk-1.2 hellogtk.c -o hellogtk cosi facendo mi ha trovato gtk.h ma mi ha dato pagine di errori in quanto sono sbagliati i percorsi include dentro a gtk.h perché sono riferiti a tutti i file di gtk guarda: or storage class /usr/include/gtk-1.2/gtk/gtkmenufactory.h:53: error: parse error before '}' token /usr/include/gtk-1.2/gtk/gtkmenufactory.h:63: error: parse error before "gchar" /usr/include/gtk-1.2/gtk/gtkmenufactory.h:63: warning: no semicolon at end of struct or union /usr/include/gtk-1.2/gtk/gtkmenufactory.h:67: error: parse error before '*' token /usr/include/gtk-1.2/gtk/gtkmenufactory.h:67: warning: data definition has no type or storage class /usr/include/gtk-1.2/gtk/gtkmenufactory.h:68: error: parse error before '}' token In file included from /usr/include/gtk-1.2/gtk/gtk.h:80, from hellogtk.c:2: /usr/include/gtk-1.2/gtk/gtkitemfactory.h:44: error: parse error before "func_data" /usr/include/gtk-1.2/gtk/gtkitemfactory.h:46: error: parse error before '*' token /usr/include/gtk-1.2/gtk/gtkitemfactory.h:46: error: parse error before '*' token /usr/include/gtk-1.2/gtk/gtkitemfactory.h:47: warning: data definition has no type or storage class /usr/include/gtk-1.2/gtk/gtkitemfactory.h:49: error: parse error before "callback_data" /usr/include/gtk-1.2/gtk/gtkitemfactory.h:67: error: field `object' has incomplete type /usr/include/gtk-1.2/gtk/gtkitemfactory.h:69: error: parse error before "gchar" /usr/include/gtk-1.2/gtk/gtkitemfactory.h:69: warning: no semicolon at end of struct or union /usr/include/gtk-1.2/gtk/gtkitemfactory.h:72: error: parse error before '*' token per pagine e pagine! pensa che ho compilato lmule e wxgtk senza problemi! |
![]() |
![]() |
![]() |
#20 |
Bannato
Iscritto dal: Mar 2003
Messaggi: 105
|
![]() ![]() ![]() |
![]() |
![]() |
![]() |
Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 05:02.