0

main.c:

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

int main()
{
    test();
    return 0;
}

test.c:

#include "test.h"

void test()
{
    printf("1");
}

test.h:

#include <stdio.h>

void test();

I use "gcc main.c", the following error occurred: /usr/bin/ld: /tmp/ccWLnzeX.o: in function main': main.c:(.text+0xa): undefined reference to test' collect2: error: ld returned 1 exit status

Karmylr
  • 29
  • 3
  • You must add all C files to your compilation command: `gcc main.c test.c -o test -Wall -Wextra -pedantic` – Gerhardh Nov 03 '22 at 10:47

0 Answers0