graywolf
graywolf copied to clipboard
Arch linux (and others?) workaround for global variables defined multiple times in different files
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
I confirm, that this is an issue in the last Fedora release (32)