Undefined reference to global variable during linking

Change your z.c to

#include "a.h"
#include "b.h"
#include "global.h"

int count; /* Definition here */
int main() {
    count = 0;
    functAb();
    functBa();
    return 0;
}

From global.h, all your files inherit the declaration of variable count but the definition is missing from all files.

You must add the definition to one of the file as int count = some_value;

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)