IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Autres éditeurs Discussion :

[MYSQL] Probleme lors de la compilation


Sujet :

Autres éditeurs

  1. #1
    Membre éprouvé
    Profil pro
    Eleveur de cornichons
    Inscrit en
    Juin 2002
    Messages
    1 074
    Détails du profil
    Informations personnelles :
    Localisation : Royaume-Uni

    Informations professionnelles :
    Activité : Eleveur de cornichons
    Secteur : Finance

    Informations forums :
    Inscription : Juin 2002
    Messages : 1 074
    Points : 1 166
    Points
    1 166
    Par défaut [MYSQL] Probleme lors de la compilation
    Bonjour !

    J'ai installer la lib MYSQL sous Linux mandrake 9.1 pour pouvoir communiquer avec une base de données Mysql.
    J'ai un problème lors de la compilation.
    Je compile avec gcc3.2 et voila la ligne de commande que je tape :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    gcc -L/usr/lib/mysql -lmysqlclient ServeurMySQL.cpp -o serveur
    Et les erreurs sont :
    /tmp/ccRwwMQn.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
    /usr/lib/mysql/libmysqlclient.so: undefined reference to `errno'
    collect2: ld returned 1 exit status
    J'ai bien libmysqlclient.a dans /usr/lib/mysql ...
    D'ou cela peut-il venir ?
    Merci

    Nas'

  2. #2
    Membre averti
    Homme Profil pro
    Inscrit en
    Avril 2002
    Messages
    290
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Secteur : Industrie

    Informations forums :
    Inscription : Avril 2002
    Messages : 290
    Points : 325
    Points
    325
    Par défaut
    Utilise g++ pour du C++.

    gcc c'est pour du C.

  3. #3
    Membre averti
    Homme Profil pro
    Inscrit en
    Avril 2002
    Messages
    290
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Secteur : Industrie

    Informations forums :
    Inscription : Avril 2002
    Messages : 290
    Points : 325
    Points
    325
    Par défaut
    Attention tu as dans le meme repertoire libmysqlclient.so et lib mysqlclient.a et par defaut il prends le premier.

  4. #4
    Membre éprouvé
    Profil pro
    Eleveur de cornichons
    Inscrit en
    Juin 2002
    Messages
    1 074
    Détails du profil
    Informations personnelles :
    Localisation : Royaume-Uni

    Informations professionnelles :
    Activité : Eleveur de cornichons
    Secteur : Finance

    Informations forums :
    Inscription : Juin 2002
    Messages : 1 074
    Points : 1 166
    Points
    1 166
    Par défaut
    Citation Envoyé par Gandalf
    Utilise g++ pour du C++.
    gcc c'est pour du C.
    Oui je sais. Mon code est du C et non du C++.

    Citation Envoyé par Gandalf
    Attention tu as dans le meme repertoire libmysqlclient.so et lib mysqlclient.a et par defaut il prends le premier.
    Que dois-je donc faire ? Déplacer libmysqlclient.so vers un autre repertoire?
    Le supprimer ?
    Merci pour ta réponse!

    Nas'

  5. #5
    Membre averti
    Homme Profil pro
    Inscrit en
    Avril 2002
    Messages
    290
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Secteur : Industrie

    Informations forums :
    Inscription : Avril 2002
    Messages : 290
    Points : 325
    Points
    325
    Par défaut
    Ton code est du C++ puisque dans un fichier .cpp... Si c'était du C il serait dans un fichier .c

    Si tu tiens à un link static ajoutes un -static avant le -lmysqlclient et alors il prendra le .a. Dans un premier temps utiliser le .so peut-etre avantageux (compil + link plus rapide).

  6. #6
    Membre éprouvé
    Profil pro
    Eleveur de cornichons
    Inscrit en
    Juin 2002
    Messages
    1 074
    Détails du profil
    Informations personnelles :
    Localisation : Royaume-Uni

    Informations professionnelles :
    Activité : Eleveur de cornichons
    Secteur : Finance

    Informations forums :
    Inscription : Juin 2002
    Messages : 1 074
    Points : 1 166
    Points
    1 166
    Par défaut
    Citation Envoyé par Gandalf
    Ton code est du C++ puisque dans un fichier .cpp... Si c'était du C il serait dans un fichier .c
    Ah oui c'est vrai ! Mon code vient d'un site, la personne n'a mis que du C pourtant dans son code mais il a mis .cpp .
    Ok j'utilise g++
    Si tu tiens à un link static ajoutes un -static avant le -lmysqlclient et alors il prendra le .a. Dans un premier temps utiliser le .so peut-etre avantageux (compil + link plus rapide).
    J'ai tapé ceci :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    g++ -L/usr/lib/mysql -static -lmysqlclient -o ServeurMySQL ServeurMySQL.cpp
    et voila les erreurs :
    /usr//bin/ld: cannot find -lstdc++
    collect2: ld returned 1 exit status
    C'est quoi ca ??
    Et si je ne met pas le -static mais que je met quand meme g++ au lieu de gcc , j'obtiens ceci :
    /usr/lib/mysql/libmysqlclient.so: undefined reference to `errno'
    collect2: ld returned 1 exit status
    Qu'y a-t-il encore ?? Me manque-t-il un fichier ?

    Nas'

  7. #7
    Membre averti
    Homme Profil pro
    Inscrit en
    Avril 2002
    Messages
    290
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Secteur : Industrie

    Informations forums :
    Inscription : Avril 2002
    Messages : 290
    Points : 325
    Points
    325
    Par défaut
    lstdc++ c'est la lib standard du C++...

    A propos de ta ligne de commande, elle n'est pas correcte...

    une lib archive ne dois jamais se trouver en début de ligne.

    essai :


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    g++ -o server ServeurMySQL.cpp -L/usr/lib/mysql -static -lmysqlclient
    voire meme

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    g++ -o server ServeurMySQL.cpp -L/usr/lib/mysql -static -lmysqlclient -dynamic
    sinon rien n'est utilisé dans la lib...
    le dynamic sert à repasser en link dynamic car il semble que tu n'ais pas certaines lib en static (stdc++)...

  8. #8
    Membre éprouvé
    Profil pro
    Eleveur de cornichons
    Inscrit en
    Juin 2002
    Messages
    1 074
    Détails du profil
    Informations personnelles :
    Localisation : Royaume-Uni

    Informations professionnelles :
    Activité : Eleveur de cornichons
    Secteur : Finance

    Informations forums :
    Inscription : Juin 2002
    Messages : 1 074
    Points : 1 166
    Points
    1 166
    Par défaut
    Je viens de taper la commande et j'ai une infinité de message d'erreur (j'ai du arrêter le défilement avec ctrl-C car ca m'a mis plus de 500lignes (sans en rajouter). Voici quelques une de ces erreurs :
    Next token is 59 (';')
    Reducing via rule 464 (line 2157), -> maybe_attribute
    state stack now 0 2 4 42 169 462 4 58 203 522
    Entering state 876
    Next token is 59 (';')
    Reducing via rule 458 (line 2125), maybe_attribute -> initdcl0_innards
    state stack now 0 2 4 42 169 462 4 58 203 522
    Entering state 875
    Reducing via rule 459 (line 2131), declarator maybeasm initdcl0_innards -> initdcl0
    state stack now 0 2 4 42 169 462 4 58
    Entering state 205
    Reducing via rule 445 (line 2073), initdcl0 -> initdecls
    state stack now 0 2 4 42 169 462 4 58
    Entering state 204
    Next token is 59 (';')
    Shifting token 59 (';'), Entering state 524
    Reducing via rule 81 (line 741), typed_declspecs initdecls ';' -> datadef
    state stack now 0 2 4 42 169 462 4
    Entering state 47
    Reducing via rule 15 (line 508), datadef -> extdef
    state stack now 0 2 4 42 169 462 4
    Entering state 38
    Reducing via rule 13 (line 497), @2 extdef -> lang_extdef
    state stack now 0 2 4 42 169 462
    Entering state 3
    Reducing via rule 5 (line 469), extdefs lang_extdef -> extdefs
    state stack now 0 2 4 42 169
    Entering state 462
    Reading a token: Next token is 261 (SCSPEC `typedef')
    Reducing via rule 12 (line 497), -> @2
    state stack now 0 2 4 42 169 462
    Entering state 4
    Next token is 261 (SCSPEC `typedef')
    Shifting token 261 (SCSPEC), Entering state 11
    Reading a token: Next token is 262 (TYPESPEC `int')
    Reducing via rule 420 (line 1946), SCSPEC -> declmods
    state stack now 0 2 4 42 169 462 4
    Entering state 60
    Next token is 262 (TYPESPEC `int')
    Shifting token 262 (TYPESPEC), Entering state 12
    Reducing via rule 436 (line 2019), TYPESPEC -> typespec
    state stack now 0 2 4 42 169 462 4 60
    Entering state 216
    Reading a token: Next token is 40 ('(')
    Reducing via rule 410 (line 1892), declmods typespec -> typed_declspecs1
    state stack now 0 2 4 42 169 462 4
    Entering state 59
    Reducing via rule 409 (line 1888), typed_declspecs1 -> typed_declspecs
    state stack now 0 2 4 42 169 462 4
    Entering state 58
    Next token is 40 ('(')
    Shifting token 40 ('('), Entering state 202
    Reading a token: Next token is 42 ('*')
    Shifting token 42 ('*'), Entering state 517
    Reading a token: Next token is 257 (IDENTIFIER `__gconv_trans_query_fct')
    Shifting token 257 (IDENTIFIER), Entering state 145
    Reading a token: Next token is 41 (')')
    Reducing via rule 313 (line 1502), IDENTIFIER -> notype_unqualified_id
    state stack now 0 2 4 42 169 462 4 58 202 517
    Entering state 158
    Next token is 41 (')')
    Reducing via rule 327 (line 1553), notype_unqualified_id -> expr_or_declarator
    state stack now 0 2 4 42 169 462 4 58 202 517
    Entering state 160
    Reducing via rule 325 (line 1543), expr_or_declarator -> expr_or_declarator_intern
    C'est tout le temps les memes sauf que des numéros changent ... qch ne tourne pas rond la :\
    Par contre, j'ai essayé un truc, c'est d'enlever le -static et j'ai déplacé le fichier libmysqlclient.so vers un autre repertoire pour voir.
    Et la ca me met juste l'erreur lstdc++ .

    Donc la j'ai essayé en déplacant à nouveau le fichier libmysqlclient.so et j'ai essayé ta commande sans le -static.
    Et voila ce que j'obtiens :
    g++ -o ServeurMySQL ServeurMySQL.cpp -L/usr/lib/mysql -lmysqlclient
    /usr/lib/mysql/libmysqlclient.a(my_malloc.o)(.text+0x53): In function `my_malloc':
    : undefined reference to `errno'
    /usr/lib/mysql/libmysqlclient.a(my_malloc.o)(.text+0x123): In function `my_memdup':
    : undefined reference to `errno'
    /usr/lib/mysql/libmysqlclient.a(my_malloc.o)(.text+0x1e1): In function `my_strdup':
    : undefined reference to `errno'
    /usr/lib/mysql/libmysqlclient.a(my_realloc.o)(.text+0x45): In function `my_realloc':
    : undefined reference to `errno'
    /usr/lib/mysql/libmysqlclient.a(my_compress.o)(.text+0x63): In function `my_compress':
    : undefined reference to `compress'
    /usr/lib/mysql/libmysqlclient.a(my_compress.o)(.text+0x127): In function `my_compress_alloc':
    : undefined reference to `compress'
    /usr/lib/mysql/libmysqlclient.a(my_compress.o)(.text+0x1a2): In function `my_uncompress':
    : undefined reference to `uncompress'
    /usr/lib/mysql/libmysqlclient.a(my_lib.o)(.text+0x2e4): In function `my_dir':
    : undefined reference to `errno'
    /usr/lib/mysql/libmysqlclient.a(my_lib.o)(.text+0x3ca): In function `my_stat':
    : undefined reference to `errno'
    /usr/lib/mysql/libmysqlclient.a(my_getwd.o)(.text+0x2f): In function `my_setwd':: undefined reference to `errno'
    /usr/lib/mysql/libmysqlclient.a(my_getwd.o)(.text+0x1a4): In function `my_getwd':
    : undefined reference to `errno'
    /usr/lib/mysql/libmysqlclient.a(my_once.o)(.text+0xa6): In function `my_once_alloc':
    : undefined reference to `errno'
    collect2: ld returned 1 exit status
    Serait-ce le fichier que j'essaye de compiler qui contient des erreurs ? Je ne pense pas car bcp de gens l'ont compilé sans probleme !
    Merci en tout cas de ton aide

    Nas'

  9. #9
    Membre averti
    Homme Profil pro
    Inscrit en
    Avril 2002
    Messages
    290
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Secteur : Industrie

    Informations forums :
    Inscription : Avril 2002
    Messages : 290
    Points : 325
    Points
    325
    Par défaut
    Ce que tu dois savoir :

    1- si tu linke avec g++ tu inclus automatiquement les lib du C++ alors que si tu liques avec gcc tu inclus celles du C.

    2- dans une lib archive tu n'utilises que ques ce qui est necessaire et qui est deja referencé, donc si elle est en début de ligne ... rien

    3- errno est une variable de la lib standard du C


    Moi j'essairais de renommer le fichier en .c et de linker avec gcc pour voir.

    ensuite es-tu sur que g++ soit bien installé, le fait qu'il ne trouve pas stdc++ est pour le moins bizzare.

  10. #10
    Membre éprouvé
    Profil pro
    Eleveur de cornichons
    Inscrit en
    Juin 2002
    Messages
    1 074
    Détails du profil
    Informations personnelles :
    Localisation : Royaume-Uni

    Informations professionnelles :
    Activité : Eleveur de cornichons
    Secteur : Finance

    Informations forums :
    Inscription : Juin 2002
    Messages : 1 074
    Points : 1 166
    Points
    1 166
    Par défaut
    J'ai renommé le fichier en .c (il ne contient aucun code C++) et voila ce que j'ai :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    [nasky@localhost nasky]# gcc -o ServerMysql ServerMysql.c -L/usr/lib/mysql -lmysqlclient
    /usr/lib/mysql/libmysqlclient.a(my_malloc.o)(.text+0x53): In function `my_malloc':
    : undefined reference to `errno'
    /usr/lib/mysql/libmysqlclient.a(my_malloc.o)(.text+0x123): In function `my_memdup':
    : undefined reference to `errno'
    /usr/lib/mysql/libmysqlclient.a(my_malloc.o)(.text+0x1e1): In function `my_strdup':
    : undefined reference to `errno'
    /usr/lib/mysql/libmysqlclient.a(my_realloc.o)(.text+0x45): In function `my_realloc':
    : undefined reference to `errno'
    /usr/lib/mysql/libmysqlclient.a(my_compress.o)(.text+0x63): In function `my_compress':
    : undefined reference to `compress'
    /usr/lib/mysql/libmysqlclient.a(my_compress.o)(.text+0x127): In function `my_compress_alloc':
    : undefined reference to `compress'
    /usr/lib/mysql/libmysqlclient.a(my_compress.o)(.text+0x1a2): In function `my_uncompress':
    : undefined reference to `uncompress'
    /usr/lib/mysql/libmysqlclient.a(my_lib.o)(.text+0x2e4): In function `my_dir':
    : undefined reference to `errno'
    /usr/lib/mysql/libmysqlclient.a(my_lib.o)(.text+0x3ca): In function `my_stat':
    : undefined reference to `errno'
    /usr/lib/mysql/libmysqlclient.a(my_getwd.o)(.text+0x2f): In function `my_setwd':
    : undefined reference to `errno'
    /usr/lib/mysql/libmysqlclient.a(my_getwd.o)(.text+0x1a4): In function `my_getwd':
    : undefined reference to `errno'
    /usr/lib/mysql/libmysqlclient.a(my_once.o)(.text+0xa6): In function `my_once_alloc':
    : undefined reference to `errno'
    collect2: ld returned 1 exit status
    La variable errno pose probleme on dirait !!!
    Sinon g++ est bien installé, j'ai vérifié.
    Y'at-il encore une solution ou bien dois-je abandonné cette lib Mysql comme j'ai du l'abandonner sous Windows ?

    Nas'

  11. #11
    Membre averti
    Homme Profil pro
    Inscrit en
    Avril 2002
    Messages
    290
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Secteur : Industrie

    Informations forums :
    Inscription : Avril 2002
    Messages : 290
    Points : 325
    Points
    325
    Par défaut
    Ce que tu ne trouves pas errno ou stdc++ sont des choses qui font parti du standard...

    soit gcc n'est pas bien installé....

    soit ce n'est pas la version à utiliser avec cette version de lib

    regarde si tu n'as pas un gcc296 ou quelque chose comme ca dans /usr/bin

Discussions similaires

  1. Probleme lors de la compilation d'un programme
    Par ToMs dans le forum wxWidgets
    Réponses: 4
    Dernier message: 15/06/2006, 18h50
  2. [utf8] Problème lors de la compilation
    Par ChipsterJulien dans le forum Editeurs / Outils
    Réponses: 1
    Dernier message: 10/03/2006, 17h36
  3. [Free Pascal] Problème lors de la compilation
    Par llaurentt dans le forum Free Pascal
    Réponses: 2
    Dernier message: 31/01/2006, 09h40
  4. Probleme lors de la compilation...
    Par Draleg dans le forum C
    Réponses: 15
    Dernier message: 08/12/2005, 17h14
  5. [Debutant] probleme lors de la compilation
    Par boobi dans le forum Débuter
    Réponses: 5
    Dernier message: 26/08/2005, 15h57

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo