How do I fix "undefined reference to 'function' in C?

1

Here is a simple example of TAD, which displays the error.

file.h

#include <stdio.h>
#include <stdlib.h>

int teste();

file.c

#include "arquivo.h"

int teste()
{
    int a=5, b=10;

    return a+b;
}

main.c

#include "arquivo.h"

int main()
{
    int r = teste();

    printf("\n\n%d\n\n",r);

    return 0;
}

And when I compile the error below appears.

    
asked by anonymous 29.11.2017 / 16:34

1 answer

2

Include the arquivo.c in the compilation, without it the function is not compiled and does not exist, so it can not be called.

    
29.11.2017 / 16:39