How do I correct "indefinite reference to 'function' in C?

Asked

Viewed 1,397 times

2

Here is a simple example of TAD, which shows 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 appears below.

referencia indefinida para a 'função'

  • More on the topic compilation: https://answall.com/a/213804/64969

1 answer

3


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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.