"undefined reference" error when compiling in C

1

I have a simple program where when compiling of an error

  

undefined reference to 'increment' |

main.c :

#include <stdio.h>
#include "incrementar.h"

int main()
{
    printf("Numero incrementado%d!", incrementar(10));
    return 0;
}


incrementar.h:

int incrementar(int i)
{
    return i++;
}



incrementar.c:

int incrementar(int i)
{
    return i++;
}

Note: I'm using Code :: Blocks.

    
asked by anonymous 23.09.2017 / 18:30

1 answer

1

You need to compile the two codes:

gcc -o main main.c incrementar.c

If Code :: Blocks did not put it on your own, you probably created the project wrongly. It has to be with Project > Add Files.

    
23.09.2017 / 18:39