Thread: undefined reference to...

  1. #1
    Registered User catasturslykid's Avatar
    Join Date
    Jul 2013
    Location
    Barcelona, Spain
    Posts
    72

    undefined reference to...

    Hi guys, this is my first post! My name is Albert and I'm from Spain! Nice to meet you!

    This is my first year programming in C and I've got a problem with my code.

    I'm using VIM editor to code and I don't know how to copy/paste the code, so I have to type it again.

    While I'm compiling, the following error appears:

    main.c: (text+0x1e2): undefined reference to 'carregaEnemics'
    main.c: (text+0x1fb): undefined reference to 'carregaClasses'

    MAIN.C:

    Code:
    #include "total.h"  
    
    
    void main(int argc, char* argv[]){
        
    FILE *f,*g,*h;
    int nCorrecte = 0, nOpcio, nEnemics, nClas;
    Classe *classes;
    Enemic *enemic;
    Personatge personatge;
    
    srand(time(NULL));
    
    f = fopen(argv[2],"r");
    if(f == NULL){
        printf("Error!\");
    }
    else{
        g = fopen(argv[3],"r");
        if(g == NULL){
            printf("Error!\n");
       }
        else{
             carregaEnemics(g,enemic,&nEnemics);
             carregaClasses(f,classes,&nClas);
    
          //There is more code but I think it's not important.
    
    ...
    }

    TOTAL.H

    Code:
    #ifndef TOTAL_H
    #define TOTAL_H
    
    #include "tipus.h"
    #include "cua.h"
    
    //That .h files include only structs.
    
    void carregaEnemics(FILE *f, Enemic *enemic, int *nEnemics);
    void carregaClasses(FILE *h, Classe *classes, int *nClas);
    
    //There are more functions but I think that they are not important to solve this problem.
    
    ...
    
    #endif
    That's all guys! Thank you for your help and sorry if I've done some mistakes while writing in english

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    So where is total.c ?

    Specifically, you should check total.c to see if
    a) you implemented carregaEnemics
    b) you spelled carregaEnemics correctly when you implemented it.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User catasturslykid's Avatar
    Join Date
    Jul 2013
    Location
    Barcelona, Spain
    Posts
    72
    Quote Originally Posted by Salem View Post
    So where is total.c ?

    Specifically, you should check total.c to see if
    a) you implemented carregaEnemics
    b) you spelled carregaEnemics correctly when you implemented it.
    I implemented it with another name! What a fail! haha Thank you, Salem!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Undefined reference?
    By Tirith in forum C Programming
    Replies: 8
    Last Post: 08-11-2009, 02:39 PM
  2. undefined reference....
    By najwani in forum C Programming
    Replies: 0
    Last Post: 04-06-2009, 10:05 PM
  3. undefined reference to...
    By funkybomber in forum C++ Programming
    Replies: 1
    Last Post: 11-26-2006, 09:59 PM
  4. undefined reference to
    By shaun84 in forum C Programming
    Replies: 12
    Last Post: 10-15-2006, 02:32 AM
  5. undefined reference
    By laasunde in forum C++ Programming
    Replies: 6
    Last Post: 10-23-2002, 11:44 AM

Tags for this Thread