Open eclipseo opened 4 years ago
For the reference, this is still an issue. Seen on Debian bookworm, which uses GCC 11.3 by default (doesn't even provide anything older than GCC 10).
@GPaulovics or others, is there a plan for fixing this? :thinking: I note that the project doesn't seem to have anything merged for the last three years...
Thanks for the pointer about the new default. This change allowed me to build with GCC 12:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e30d9fd..9493147 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,3 +1,5 @@
+add_compile_options(-fcommon)
+
IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} VERSION_LESS 3.1)
set(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake > 2.8.4 is required
cmake_minimum_required(VERSION 2.8)
edit: better use the patch from #535 actually.
With the latest GCC 10 (in Fedora Rawhide), lastpass-cli fails to build:
This is related to this change in GCC 10:
GCC now defaults to -fno-common. As a result, global variable accesses are more efficient on various targets. In C, global variables with multiple tentative definitions now result in linker errors. With -fcommon such definitions are silently merged during linking.
https://gcc.gnu.org/gcc-10/changes.html
Default to -fno-common
A common mistake in C is omitting extern when declaring a global variable in a header file. If the header is included by several files it results in multiple definitions of the same variable. In previous GCC versions this error is ignored. GCC 10 defaults to -fno-common, which means a linker error will now be reported. To fix this, use extern in header files when declaring global variables, and ensure each global is defined in exactly one C file. As a workaround, legacy C code can be compiled with -fcommon.
https://gcc.gnu.org/gcc-10/porting_to.html