Programmation C++
Ben
-
Marcel -
Marcel -
Bonjour,
J'ai un petit problème dans la compilation (ou plutôt) au moment de l'édition des liens.
J'ai fait un petit prog tout basic :
#include <iostream>
#include <stdio.h>
using namespace std;
int
maint(void) {
cout << "Hello World !" << endl;
return EXIT_SUCCESS;
}
J'utilise un Makefile simple :
OPTIONS= -Wall -g
LDFLAGS= -L/usr/X11R6/lib
SRCS= helloWorld.cpp
OBJS=$(SRCS:.cpp=.o)
TOTO_OBJS= helloWorld.o
exo1: $(TOTO_OBJS)
g++ $(OPTIONS) $(LDFLAGS) $(TOTO_OBJS) -o $@
clean :
-rm -f $(TARGET) *.o
Lorsque je lance "make", j'obtiens alors :
g++ -c -o helloWorld.o helloWorld.cpp
g++ -Wall -g -L/usr/X11R6/lib helloWorld.o -o exo1
/usr/lib/gcc/i586-mandrake-linux-gnu/3.4.1/../../../crt1.o(.text+0x18): In function `_start':
../sysdeps/i386/elf/start.S:98: undefined reference to `main'
collect2: ld returned 1 exit status
make: *** [exo1] Erreur 1
J'y comprend pas grand chose.
Je viens juste d'installer Mandrake 10.1 Community en spécifiant les bons packages à l'installation.
Merci pour votre aide.
J'ai un petit problème dans la compilation (ou plutôt) au moment de l'édition des liens.
J'ai fait un petit prog tout basic :
#include <iostream>
#include <stdio.h>
using namespace std;
int
maint(void) {
cout << "Hello World !" << endl;
return EXIT_SUCCESS;
}
J'utilise un Makefile simple :
OPTIONS= -Wall -g
LDFLAGS= -L/usr/X11R6/lib
SRCS= helloWorld.cpp
OBJS=$(SRCS:.cpp=.o)
TOTO_OBJS= helloWorld.o
exo1: $(TOTO_OBJS)
g++ $(OPTIONS) $(LDFLAGS) $(TOTO_OBJS) -o $@
clean :
-rm -f $(TARGET) *.o
Lorsque je lance "make", j'obtiens alors :
g++ -c -o helloWorld.o helloWorld.cpp
g++ -Wall -g -L/usr/X11R6/lib helloWorld.o -o exo1
/usr/lib/gcc/i586-mandrake-linux-gnu/3.4.1/../../../crt1.o(.text+0x18): In function `_start':
../sysdeps/i386/elf/start.S:98: undefined reference to `main'
collect2: ld returned 1 exit status
make: *** [exo1] Erreur 1
J'y comprend pas grand chose.
Je viens juste d'installer Mandrake 10.1 Community en spécifiant les bons packages à l'installation.
Merci pour votre aide.
A voir également:
- Programmation C++
- Application de programmation - Guide
- Programmation envoi sms - Guide
- Programmation vb - Télécharger - Langages
- Programmation binaire - Guide
- Programmation télécommande porte de garage brico depot - Forum Matériel & Système
4 réponses
salut!
#include <cstdio> /* pour C++ */
au lieu de
#include <stdio.h> /* pour C */
main
au lieu de
maint
ici <cstdio> n'est d'aucune utilité car aucune fonction de la bibliothèque associée n'est utilisée.
ici <cstdlib> est nécessaire pour l'utilisation de la macro EXIT_SUCCESS
En gros esssaie plutôt ça:
#include <cstdlib>
#include <iostream>
using std namespace;
int main(void)
{
cout << "hello world!" << endl;
return EXIT_SUCCESS;
}
#include <cstdio> /* pour C++ */
au lieu de
#include <stdio.h> /* pour C */
main
au lieu de
maint
ici <cstdio> n'est d'aucune utilité car aucune fonction de la bibliothèque associée n'est utilisée.
ici <cstdlib> est nécessaire pour l'utilisation de la macro EXIT_SUCCESS
En gros esssaie plutôt ça:
#include <cstdlib>
#include <iostream>
using std namespace;
int main(void)
{
cout << "hello world!" << endl;
return EXIT_SUCCESS;
}