royallgroup / TCC

The Topological Cluster Classification algorithm
https://royallgroup.github.io/TCC/
GNU General Public License v3.0
12 stars 5 forks source link

Linking failure with duplicate symbols #138

Open yangyushi opened 1 year ago

yangyushi commented 1 year ago

People will get duplicate symbol error during linking.

I get the following error when trying to build TCC with gcc 12. The very easy fix is to use gcc-9 or clang.

...
duplicate symbol '_min_cutAA2' in:
    CMakeFiles/tcc.dir/bonds.c.o
    CMakeFiles/tcc.dir/voronoi_bonds.c.o
ld: 11271 duplicate symbols for architecture x86_64
collect2: error: ld returned 1 exit status
make[2]: *** [src/tcc] Error 1
make[1]: *** [src/CMakeFiles/tcc.dir/all] Error 2
make: *** [all] Error 2

I think it is related to the change of default linker flag since gcc 10.

We can remove this error by define the global variables better. I will try to make a pull request about this.

yangyushi commented 1 year ago

Using

cmake .. -DCMAKE_C_FLAGS=-fcommon

to generate Makefile is also one way to get around this issue~