gphocs-dev / G-PhoCS

G-PhoCS is a software package for inferring ancestral population sizes, population divergence times, and migration rates from individual genome sequences.
33 stars 4 forks source link

Multiple definitions error when compiling #86

Closed milesandersonmn closed 2 years ago

milesandersonmn commented 2 years ago

Compiling the Makefile with GCC 11.2.1 throws a multiple definition error:

/usr/bin/ld: obj/MCMCcontrol.o:(.bss+0x140): multiple definition of `ioSetup'; obj/GPhoCS.o:(.bss+0x1040): first defined here
/usr/bin/ld: obj/MCMCcontrol.o:(.bss+0xa0): multiple definition of `mcmcSetup'; obj/GPhoCS.o:(.bss+0xfa0): first defined here
/usr/bin/ld: obj/MCMCcontrol.o:(.bss+0x60): multiple definition of `dataSetup'; obj/GPhoCS.o:(.bss+0xf60): first defined here
/usr/bin/ld: obj/MCMCcontrol.o:(.bss+0x40): multiple definition of `admixed_samples'; obj/GPhoCS.o:(.bss+0xf40): first defined here
/usr/bin/ld: obj/AlignmentProcessor.o:(.bss+0x740): multiple definition of `AlignmentData'; obj/GPhoCS.o:(.bss+0xf00): first defined here
/usr/bin/ld: obj/AlignmentProcessor.o:(.bss+0x700): multiple definition of `PhasedPatterns'; obj/GPhoCS.o:(.bss+0xec0): first defined here
/usr/bin/ld: obj/patch.o:(.bss+0xee0): multiple definition of `dataSetup'; obj/GPhoCS.o:(.bss+0xf60): first defined here
/usr/bin/ld: obj/patch.o:(.bss+0xeb8): multiple definition of `locus_data'; obj/GPhoCS.o:(.bss+0xe38): first defined here
/usr/bin/ld: obj/patch.o:(.bss+0xeb0): multiple definition of `nodePops'; obj/GPhoCS.o:(.bss+0xe30): first defined here
/usr/bin/ld: obj/patch.o:(.bss+0xea8): multiple definition of `nodeEvents'; obj/GPhoCS.o:(.bss+0xe28): first defined here
/usr/bin/ld: obj/patch.o:(.bss+0xe60): multiple definition of `genetree_migs'; obj/GPhoCS.o:(.bss+0xde0): first defined here
/usr/bin/ld: obj/patch.o:(.bss+0xe50): multiple definition of `genetree_stats'; obj/GPhoCS.o:(.bss+0xdd0): first defined here
/usr/bin/ld: obj/patch.o:(.bss+0xe48): multiple definition of `genetree_stats_total_partitioned'; obj/GPhoCS.o:(.bss+0xdc8): first defined here
/usr/bin/ld: obj/patch.o:(.bss+0xe58): multiple definition of `event_chains'; obj/GPhoCS.o:(.bss+0xdd8): first defined here
/usr/bin/ld: obj/patch.o:(.bss+0x100): multiple definition of `genetree_stats_flat'; obj/GPhoCS.o:(.bss+0x80): first defined here
/usr/bin/ld: obj/patch.o:(.bss+0x80): multiple definition of `genetree_node_stats'; obj/GPhoCS.o:(.bss+0x0): first defined here
/usr/bin/ld: obj/patch.o:(.bss+0xec0): multiple definition of `admixed_samples'; obj/GPhoCS.o:(.bss+0xf40): first defined here
/usr/bin/ld: obj/patch.o:(.bss+0xe80): multiple definition of `admixture_status'; obj/GPhoCS.o:(.bss+0xe00): first defined here
/usr/bin/ld: obj/patch.o:(.bss+0x20): multiple definition of `dataState'; obj/GPhoCS.o:(.bss+0xe60): first defined here
/usr/bin/ld: obj/patch.o:(.bss+0x7c0): multiple definition of `genetree_stats_total'; obj/GPhoCS.o:(.bss+0x740): first defined here
/usr/bin/ld: obj/patch.o:(.bss+0x120): multiple definition of `genetree_stats_total_check'; obj/GPhoCS.o:(.bss+0xa0): first defined here
/usr/bin/ld: obj/patch.o:(.bss+0x8): multiple definition of `misc_stats'; obj/GPhoCS.o:(.bss+0xe40): first defined here
/usr/bin/ld: obj/patch.o:(.bss+0x50): multiple definition of `typeCount'; obj/GPhoCS.o:(.bss+0xe90): first defined here
/usr/bin/ld: obj/patch.o:(.bss+0xf20): multiple definition of `mcmcSetup'; obj/GPhoCS.o:(.bss+0xfa0): first defined here
/usr/bin/ld: obj/patch.o:(.bss+0xfc0): multiple definition of `ioSetup'; obj/GPhoCS.o:(.bss+0x1040): first defined here
collect2: error: ld returned 1 exit status
make: *** [Makefile:50: bin/G-PhoCS] Error 1

I'm attempting to set the CFLAGs using -fcommon but so far having no luck. If anyone is aware of an easy way to fix this, I would appreciate it. otherwise I'll continue working on it and update a solution if I find one.

milesandersonmn commented 2 years ago

Ok that was quick. For anyone compiling with GCC 11 (and maybe 10), you can append -fcommon to the CFLAGs in line 17 like this:

CFLAGS+= -fstack-protector-all -Wall -O3  -std=c99 -fcommon

If you've already run make without the editted line though, you need to run command "make clean" then run the make command again and it will work.

gphocs-dev commented 2 years ago

Thanks, Miles. --Ilan

On Fri, Oct 21, 2022 at 3:50 PM Miles Anderson @.***> wrote:

Closed #86 https://github.com/gphocs-dev/G-PhoCS/issues/86 as completed.

— Reply to this email directly, view it on GitHub https://github.com/gphocs-dev/G-PhoCS/issues/86#event-7640883530, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADO7ILXAO5TDNHFU2Y3VO7LWEKNSDANCNFSM6AAAAAARLFX5FA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

mkweskin commented 4 months ago

Thanks for posting this. I can confirm that gcc 10.1.0 was giving these compilation errors and adding -fcommon to CFLAGS fixed it.