Skip to content

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

Description

@RTimothyEdwards

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions