BIC-MNI / minc-tools

Basic minc-tools from former minc repository
Other
29 stars 25 forks source link

Fix build error with GCC 10 due to missing … #108

Closed smr99 closed 4 years ago

smr99 commented 4 years ago

GCC version 10 now defaults to -fno-common; see https://gcc.gnu.org/gcc-10/porting_to.html. The practical result of this is a compile error in minctoecat due to multiple definitions; see below.

Fix is to add "extern" modifier to matrix_errno and matrix_errtxt declarations in ecat_write.h; define these two in ecat_write.c.

FAILED: conversion/minctoecat : && /usr/bin/cc -rdynamic conversion/CMakeFiles/minctoecat.dir/minctoecat/minctoecat.c.o conversion/CMakeFiles/minctoecat.dir/minctoecat/ecat_write.c.o conversion/CMakeFiles/minctoecat.dir/minctoecat/machine_indep.c.o -o conversion/minctoecat -Wl,-rpath,/usr/lib/x86_64-linux-gnu/hdf5/serial: -lminc2 /usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5.so -lpthread -lsz -lz -ldl -lm -lz -lm -ldl -lrt -lnetcdf -lminc2 -lminc2 /usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5.so -lpthread -lsz -lz -ldl -lm -lz -lm -ldl -lrt -lnetcdf -lm -lminc2 /usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5.so -lpthread -lsz -lz -ldl -lm -ldl -lrt -lnetcdf -lminc2 /usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5.so -lpthread -lsz -lz -ldl -lm -lm -ldl -lrt -lnetcdf && : /usr/bin/ld: conversion/CMakeFiles/minctoecat.dir/minctoecat/ecat_write.c.o:(.bss+0x0): multiple definition of matrix_errno'; conversion/CMakeFiles/minctoecat.dir/minctoecat/minctoecat.c.o:(.bss+0x0): first defined here /usr/bin/ld: conversion/CMakeFiles/minctoecat.dir/minctoecat/ecat_write.c.o:(.bss+0x20): multiple definition ofmatrix_errtxt'; conversion/CMakeFiles/minctoecat.dir/minctoecat/minctoecat.c.o:(.bss+0x20): first defined here /usr/bin/ld: conversion/CMakeFiles/minctoecat.dir/minctoecat/machine_indep.c.o:(.bss+0x0): multiple definition of matrix_errno'; conversion/CMakeFiles/minctoecat.dir/minctoecat/minctoecat.c.o:(.bss+0x0): first defined here /usr/bin/ld: conversion/CMakeFiles/minctoecat.dir/minctoecat/machine_indep.c.o:(.bss+0x20): multiple definition ofmatrix_errtxt'; conversion/CMakeFiles/minctoecat.dir/minctoecat/minctoecat.c.o:(.bss+0x20): first defined here collect2: error: ld returned 1 exit status

gdevenyi commented 4 years ago

Thanks @smr99! What version of gcc triggers this? I have been building develop on gcc-10 (Ubuntu 10.1.0-2ubuntu1~18.04) 10.1.0 and haven't triggered this bug

smr99 commented 4 years ago

On Saturday, July 25, 2020 12:09:37 P.M. CDT Gabriel A. Devenyi wrote:

Thanks @smr99! What version of gcc triggers this? I have been building develop on gcc-10 (Ubuntu 10.1.0-2ubuntu1~18.04) 10.1.0 and haven't triggered this bug

Given that the default to -fno-common is described on the gcc-10 page, I'd assume it happens in any revision of gcc 10. I'm using the Debian build:

steve@riemann:~/Packages/minc/minc-tools$ gcc --version gcc (Debian 10.1.0-6) 10.1.0

Possibly Ubuntu has modified the defaults in their build?

Regards, -Steve

gdevenyi commented 4 years ago

Confirmed, Ubuntu keeps "-fcommon" in the default configuration of gcc-10, while debian dropped it: https://changelogs.ubuntu.com/changelogs/pool/main/g/gcc-10/gcc-10_10-20200411-0ubuntu1/changelog

Tested with

gcc-10 -Q -v test.c 2>&1 | grep  common

In ubnuntu vs debian 10.

Thanks!

gdevenyi commented 4 years ago

@vfonov forgot to pull this in as well which breaks a few of the builds which default to -fno-common. We can either pull in, or I can add -fcommon to the build for now.

vfonov commented 4 years ago

there are more changes incoming to satisfy more strict clang as well, so better include this in 1.9.18 release.