I'm getting multiple definition of global variable errors when I try to compile:
/usr/bin/ld: ../grpc/server.o:(.bss+0x0): multiple definition of `TABLET[abi:cxx11]'; backend_server.o:(.bss+0x0): first defined here
/usr/bin/ld: ../grpc/server.o:(.data+0x0): multiple definition of `VB'; backend_server.o:(.data+0x0): first defined here
/usr/bin/ld: file_reader_functions/password_reader.o:(.bss+0x0): multiple definition of `TABLET[abi:cxx11]'; backend_server.o:(.bss+0x0): first defined here
/usr/bin/ld: file_reader_functions/password_reader.o:(.data+0x0): multiple definition of `VB'; backend_server.o:(.data+0x0): first defined here
/usr/bin/ld: file_reader_functions/file_writer.o:(.bss+0x0): multiple definition of `TABLET[abi:cxx11]'; backend_server.o:(.bss+0x0): first defined here
/usr/bin/ld: file_reader_functions/file_writer.o:(.data+0x0): multiple definition of `VB'; backend_server.o:(.data+0x0): first defined here
I define my global variables in backend/globals.h:
#pragma once
#include <unordered_map>
#include <string>
using namespace std;
unordered_map<string, unordered_map<string, char*>> TABLET;
bool VB = true; // Verbose
Then in each file where I use these global variables, I simply include this globals.h file.
I'm 100% certain I'm not redefining the global variables anywhere else, nor am I using extern.
I've also tried with the old school header guards:
#ifndef GLOBALS_H
#define GLOBALS_H
#include <unordered_map>
#include <string>
using namespace std;
unordered_map<string, unordered_map<string, char*>> TABLET;
bool VB = true; // Verbose
#endif
Any reasons why I'm getting this issue?