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

C Discussion :

hello1.c:(.text+0x18): undefined reference to `fopen'


Sujet :

C

  1. #1
    Membre du Club
    Profil pro
    Inscrit en
    Mai 2006
    Messages
    233
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2006
    Messages : 233
    Points : 60
    Points
    60
    Par défaut hello1.c:(.text+0x18): undefined reference to `fopen'
    en essayant de compiler mon programme, j'ai le message d'erreur suiavnt:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
     
    hello1.o: In function `Hello':
    hello1.c:(.text+0x18): undefined reference to `fopen'
    hello1.c:(.text+0x24): undefined reference to `OS_ScrInit'
    hello1.c:(.text+0x2c): undefined reference to `puts'
    hello1.c:(.text+0x3c): undefined reference to `fclose'
    ecran.o: In function `_start':
    ecran.c:(.text+0x18): undefined reference to `printf'
    ecran.c:(.text+0x30): undefined reference to `GetScreenSize'
    make: *** [hello1] Error 1
    sachant que j'ai bien inclue le fichier .h qui contient le prototype de ces fonctions,
    qq1 peut me dire de quoi sagit ces .text+0x18

    merci

  2. #2
    Expert éminent sénior
    Avatar de Emmanuel Delahaye
    Profil pro
    Retraité
    Inscrit en
    Décembre 2003
    Messages
    14 512
    Détails du profil
    Informations personnelles :
    Âge : 67
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Retraité

    Informations forums :
    Inscription : Décembre 2003
    Messages : 14 512
    Points : 20 985
    Points
    20 985
    Par défaut
    Citation Envoyé par moon93
    qq1 peut me dire de quoi sagit ces .text+0x18
    Problème d'édition de lien (manque la bibliothèque standard).
    Quel est ton environnement de développement ?
    (Machine, système, compilateur, IDE...)

  3. #3
    Membre du Club
    Profil pro
    Inscrit en
    Mai 2006
    Messages
    233
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2006
    Messages : 233
    Points : 60
    Points
    60
    Par défaut
    j'utilise GCC_3.4.3 sous windows, dans mon make file j'ai bien spécifié le chemin des librairies, mais!!!!
    le fichier qui contien le prototype de ces fonction est OEM.h, je l'ai inclu mais j'ai toujours le msg d'erreur:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
     
    hello1.c:2:17: OEM.H: No such file or directory
    hello1.c: In function `Hello':
    hello1.c:6: error: `FILE' undeclared (first use in this function)
    hello1.c:6: error: (Each undeclared identifier is reported only once
    hello1.c:6: error: for each function it appears in.)
    hello1.c:6: error: `visu' undeclared (first use in this function)
    hello1.c:9: warning: implicit declaration of function `fopen'
    hello1.c:10: warning: implicit declaration of function `OS_ScrInit'
    hello1.c:11: warning: implicit declaration of function `puts'
    hello1.c:14: warning: implicit declaration of function `fclose'
    hello1.c:17:2: warning: no newline at end of file
    make: *** [hello1.o] Error 1

  4. #4
    Membre régulier
    Profil pro
    Inscrit en
    Mai 2006
    Messages
    138
    Détails du profil
    Informations personnelles :
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations forums :
    Inscription : Mai 2006
    Messages : 138
    Points : 124
    Points
    124
    Par défaut
    c bizarre on dirait qu'il ne reconnait aucun de tes fichiers.h
    tu es sur que tes include dans ton code correspondent bien avec le chemin indiqué dans ton Makefile ?

  5. #5
    Expert éminent sénior
    Avatar de Emmanuel Delahaye
    Profil pro
    Retraité
    Inscrit en
    Décembre 2003
    Messages
    14 512
    Détails du profil
    Informations personnelles :
    Âge : 67
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Retraité

    Informations forums :
    Inscription : Décembre 2003
    Messages : 14 512
    Points : 20 985
    Points
    20 985
    Par défaut
    Citation Envoyé par moon93
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    hello1.c:2:17: OEM.H: No such file or directory
    Là, c'est autre chose. Le fichier oem.h n'a pas été trouvé (et attention, OEM.H et oem.h pourrait très bien être des fichiers différents. Ca dépend du système et du logiciel qui les utilise...).

    Montre la ligne de commande de gcc.

  6. #6
    Membre régulier
    Profil pro
    Inscrit en
    Mai 2006
    Messages
    138
    Détails du profil
    Informations personnelles :
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations forums :
    Inscription : Mai 2006
    Messages : 138
    Points : 124
    Points
    124
    Par défaut
    deja tu n'a plus l'erreur sur le printf ce qui laisse suposé quand meme que tu avais des probleme avec les include mais si tu montrer a la fois ton code et tes commande gcc on y verrais plus clair

  7. #7
    Membre du Club
    Profil pro
    Inscrit en
    Mai 2006
    Messages
    233
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2006
    Messages : 233
    Points : 60
    Points
    60
    Par défaut
    mon Makefile est le suivant:
    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
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
     
     
    CFLAGS=-Wall
    #CHC - CFLAGS=-Wall -ansi
    #LDFLAGS=-Wall -ansi
     
    #SDK_DIR    = D:\SDK30\Version4.3\SDK
    SDK_INC    = D:/SDK30/Version4.3/SDK/Inc
    SDK_LIB    = D:/SDK30/Version4.3/SDK/Lib_gnu
    DEFINES    = -D_EFT30_ -D_EXPORT_
     
    GNU_VERSION = 3.4.3
     
    GNU_DIR      = C:/GCC_$(GNU_VERSION)
    GNU_BIN_DIR  = $(GNU_DIR)/bin
     
    GNU_TARGET   = arm-elf
    GNU_LIB_TYPE = thumb/soft/interwork
     
    GNU_LIB_DIR_1 = $(GNU_DIR)\$(GNU_TARGET)\lib\$(GNU_LIB_TYPE)
    GNU_LIB_DIR_2 = $(GNU_DIR)\lib\gcc\$(GNU_TARGET)\$(GNU_VERSION)\$(GNU_LIB_TYPE)
     
    GNU_LINKER = $(GNU_BIN_DIR)/$(GNU_TARGET)-ld
    GNU_COMPILER = $(GNU_BIN_DIR)/$(GNU_TARGET)-gcc
     
    #LDFLAGS= "$(GNU_LIB_DIR_1)"  -L "$(GNU_LIB_DIR_2)" -lc -lgcc 
     
    INCLUDES   = -I $(SDK_INC)
     
    LIBS       = -L $(SDK_LIB)/eft30.lib "$(GNU_LIB_DIR_1)" -lc -L "$(GNU_LIB_DIR_2)" -lgcc
    #LIBS       = -L "$(SDK_LIB)"
     
    EXEC=hello1
     
    all: $(EXEC)
     
    hello1: hello1.o ecran.o
    	$(GNU_LINKER) $(LIBS) -o hello1 hello1.o ecran.o  $(INCLUDES) 
    	#$(LDFLAGS)
     
    hello1.o: hello1.c
    	$(GNU_COMPILER)  $(INCLUDES) $(CFLAGS) -o hello1.o -c hello1.c  
     
    ecran.o: ecran.c hello1.h
    	$(GNU_COMPILER)  $(INCLUDES) $(CFLAGS) -o ecran.o -c ecran.c   
    .PHONY: clean mrproper
     
    clean:
    	rm -rf *.o
     
    mrproper: clean
    	rm -rf $(EXEC)*
    le chemin des LIBs est bien spécifé non?

  8. #8
    Membre du Club
    Profil pro
    Inscrit en
    Mai 2006
    Messages
    233
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2006
    Messages : 233
    Points : 60
    Points
    60
    Par défaut
    j'ai modifier l'emplacement de mes fichiers .h, j'ai choisi un chemin court:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
    SDK_INC    = C:\SDK\inc
    SDK_LIB    = C:\SDK\lib_gnu
    et la j'ai un grand nombre d'erreurs, dans des fichiers .h que j'ai meme pas inclus!!!!!!!!, voici une partie:
    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
     
    In file included from C:/SDK/inc/ta_appli.h:1,
                     from C:/SDK/inc/SDK30.H:2,
                     from hello1.c:1:
    C:/SDK/inc/oem.h:13: error: parse error before '/' token
    C:/SDK/inc/oem.h:14: error: missing terminating ' character
    C:/SDK/inc/oem.h:16: error: syntax error at '#' token
    In file included from C:/SDK/inc/oem.h:18,
                     from C:/SDK/inc/ta_appli.h:1,
                     from C:/SDK/inc/SDK30.H:2,
                     from hello1.c:1:
    /cygdrive/c/GCC_3.4.3/bin/../lib/gcc/arm-elf/3.4.3/include/stdarg.h:105: error: parse error before "va_list"
    In file included from C:/SDK/inc/ta_appli.h:1,
                     from C:/SDK/inc/SDK30.H:2,
                     from hello1.c:1:
    C:/SDK/inc/oem.h:19:22: warning: extra tokens at end of #include directive
    qq1, peut m'aider, franchement je comprend rien

  9. #9
    Expert éminent sénior
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 381
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 381
    Points : 41 580
    Points
    41 580
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Parse error before '/' token
    Quels sont tes options de compilation?
    Si tu compiles en -ansi et qu'il y a un commentaire uniligne dans OEM.h, cela peut peut-être provoquer cette erreur...

  10. #10
    Membre du Club
    Profil pro
    Inscrit en
    Mai 2006
    Messages
    233
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2006
    Messages : 233
    Points : 60
    Points
    60
    Par défaut
    ta raison Médinoc,
    j'ai enlevé l'option -ansi , et ça ma donner bcp moins d'erreurs:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
    C:\DOCUME~1\abdel\LOCALS~1\Temp\make9762.sh: C:GCC_3.4.3binarm-elf-ld: command not found
    make: *** [hello1] Error 127
    mon chemin du linker est bien correcte mais, mais dans le message, il m'affiche pas les '/'!!!!!

Discussions similaires

  1. winsock.h : undefined reference...
    Par abraxas dans le forum Dev-C++
    Réponses: 14
    Dernier message: 06/08/2012, 13h42
  2. Réponses: 2
    Dernier message: 21/08/2011, 12h25
  3. Réponses: 8
    Dernier message: 22/07/2008, 14h30
  4. hello1.c:(.text+0x18): undefined reference to `fopen'
    Par moon93 dans le forum Autres éditeurs
    Réponses: 3
    Dernier message: 15/06/2006, 12h18
  5. g++ : undefined reference to ...
    Par le_barbu dans le forum Autres éditeurs
    Réponses: 16
    Dernier message: 14/05/2004, 07h23

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