---
title: "Ubuntu 22.04.1 : GCC 11 ( -fcommon ) : Issue … Multiple definition of."
url: https://www.cyber-neurones.org/2022/09/ubuntu-22-04-1-gcc-11-fcommon-issue-multiple-definition-of/
date: 2022-09-05
modified: 2022-09-05
lang: fr
author: "Frederic"
description: "Avec GCC 11 on a changer la valeur par défaut. GCC 11 : -fno-common (Release note : https://gcc.gnu.org/gcc-11/changes.html ) GCC 10 : -fcommon Donc pour supprimer les problèmes (de facon..."
categories:
  - "Ubuntu"
tags:
  - "GCC"
  - "Ubuntu"
word_count: 224
---

# Ubuntu 22.04.1 : GCC 11 ( -fcommon ) : Issue … Multiple definition of.

Avec GCC 11 on a changer la valeur par défaut.

- GCC 11 : -fno-common (Release note : [https://gcc.gnu.org/gcc-11/changes.html](https://gcc.gnu.org/gcc-11/changes.html) )
- GCC 10 : -fcommon

Donc pour supprimer les problèmes (de facon rapide) il suffit d'ajouter la directive -fcommon. La solution idéale est de revoir le code ... et surtout les .h.

Misère.

Pour information Ubuntu **22.04.1** utilise gcc **11.2.0-19** .
La doc : [https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html](https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html)

> **-fcommon**
>
>
> In C code, this option controls the placement of global variables defined without an initializer, known as *tentative definitions* in the C standard. Tentative definitions are distinct from declarations of a variable with the extern keyword, which do not allocate storage.
>
>
> The default is -fno-common, which specifies that the compiler places uninitialized global variables in the BSS section of the object file. This inhibits the merging of tentative definitions by the linker so you get a multiple-definition error if the same variable is accidentally defined in more than one compilation unit.
>
>
> The -fcommon places uninitialized global variables in a common block. This allows the linker to resolve all tentative definitions of the same variable in different compilation units to the same object, or to a non-tentative definition. **This behavior is inconsistent with C++, and on many targets implies a speed and code size penalty on global variable references.** It is mainly useful to enable legacy code to link without errors.