graywolf icon indicating copy to clipboard operation
graywolf copied to clipboard

Arch linux (and others?) workaround for global variables defined multiple times in different files

Open RTimothyEdwards opened this issue 4 years ago • 6 comments

At least in Arch linux, and probably others, the linker stage fails because gcc is configured to define "-fno-common" by default, and so it becomes illegal to declare a global variable of the same name in more than one C file that are going to be linked into the same object file.

The workaround is to add

set(CMAKE_C_FLAGS "-fcommon") set(CMAKE_CXX_FLAGS "-fcommon")

to CMakeLists.txt.

The real fix would be to set -fno-common to force the compiler error and then fix all the instances where global variables have been defined more than once in files being linked together.

---Tim

RTimothyEdwards avatar Jun 27 '20 20:06 RTimothyEdwards

I confirm, that this is an issue in the last Fedora release (32)

belohoub avatar Jul 21 '20 21:07 belohoub