Skip to content

multiple definition of `THREAD_NUM' during compilation #10

@maxdudek

Description

@maxdudek

Hi,

After running make I got the following output and error:

gcc -fopenmp -DNDEBUG -D_FORTIFY_SOURCE=2 -O2  -c -o src/esthmm.o src/esthmm.c
gcc -fopenmp -DNDEBUG -D_FORTIFY_SOURCE=2 -O2  -c -o src/BaumWelch.o src/BaumWelch.c
gcc -fopenmp -DNDEBUG -D_FORTIFY_SOURCE=2 -O2  -c -o src/nrutil.o src/nrutil.c
gcc -fopenmp -DNDEBUG -D_FORTIFY_SOURCE=2 -O2  -c -o src/hmmutils.o src/hmmutils.c
gcc -fopenmp -DNDEBUG -D_FORTIFY_SOURCE=2 -O2  -c -o src/emutils.o src/emutils.c
gcc -fopenmp -DNDEBUG -D_FORTIFY_SOURCE=2 -O2  -c -o src/logmath.o src/logmath.c
gcc -fopenmp -DNDEBUG -D_FORTIFY_SOURCE=2 -O2  -c -o src/fwd_bwd.o src/fwd_bwd.c
gcc -fopenmp -DNDEBUG -D_FORTIFY_SOURCE=2 -O2  -c -o src/viterbi.o src/viterbi.c
gcc -fopenmp -DNDEBUG -D_FORTIFY_SOURCE=2 -O2  -c -o src/fileutils.o src/fileutils.c
gcc -fopenmp -fcommon -lgsl -lgslcblas -o TRACE src/esthmm.o src/nrutil.o \
    src/emutils.o src/hmmutils.o src/logmath.o src/fwd_bwd.o \
    src/BaumWelch.o src/viterbi.o src/fileutils.o -lm
/cm/shared/easybuild/software/binutils/2.38-GCCcore-11.3.0/bin/ld: src/nrutil.o:(.bss+0x0): multiple definition of `THREAD_NUM'; src/esthmm.o:(.bss+0x0): first defined here
/cm/shared/easybuild/software/binutils/2.38-GCCcore-11.3.0/bin/ld: src/nrutil.o:(.bss+0x4): multiple definition of `MAXITERATION'; src/esthmm.o:(.bss+0x4): first defined here
/cm/shared/easybuild/software/binutils/2.38-GCCcore-11.3.0/bin/ld: src/emutils.o:(.bss+0x0): multiple definition of `THREAD_NUM'; src/esthmm.o:(.bss+0x0): first defined here
/cm/shared/easybuild/software/binutils/2.38-GCCcore-11.3.0/bin/ld: src/emutils.o:(.bss+0x4): multiple definition of `MAXITERATION'; src/esthmm.o:(.bss+0x4): first defined here
/cm/shared/easybuild/software/binutils/2.38-GCCcore-11.3.0/bin/ld: src/hmmutils.o:(.bss+0x0): multiple definition of `THREAD_NUM'; src/esthmm.o:(.bss+0x0): first defined here
/cm/shared/easybuild/software/binutils/2.38-GCCcore-11.3.0/bin/ld: src/hmmutils.o:(.bss+0x4): multiple definition of `MAXITERATION'; src/esthmm.o:(.bss+0x4): first defined here
/cm/shared/easybuild/software/binutils/2.38-GCCcore-11.3.0/bin/ld: src/logmath.o:(.bss+0x0): multiple definition of `THREAD_NUM'; src/esthmm.o:(.bss+0x0): first defined here
/cm/shared/easybuild/software/binutils/2.38-GCCcore-11.3.0/bin/ld: src/logmath.o:(.bss+0x4): multiple definition of `MAXITERATION'; src/esthmm.o:(.bss+0x4): first defined here
/cm/shared/easybuild/software/binutils/2.38-GCCcore-11.3.0/bin/ld: src/fwd_bwd.o:(.bss+0x0): multiple definition of `THREAD_NUM'; src/esthmm.o:(.bss+0x0): first defined here
/cm/shared/easybuild/software/binutils/2.38-GCCcore-11.3.0/bin/ld: src/fwd_bwd.o:(.bss+0x4): multiple definition of `MAXITERATION'; src/esthmm.o:(.bss+0x4): first defined here
/cm/shared/easybuild/software/binutils/2.38-GCCcore-11.3.0/bin/ld: src/BaumWelch.o:(.bss+0x0): multiple definition of `THREAD_NUM'; src/esthmm.o:(.bss+0x0): first defined here
/cm/shared/easybuild/software/binutils/2.38-GCCcore-11.3.0/bin/ld: src/BaumWelch.o:(.bss+0x4): multiple definition of `MAXITERATION'; src/esthmm.o:(.bss+0x4): first defined here
/cm/shared/easybuild/software/binutils/2.38-GCCcore-11.3.0/bin/ld: src/viterbi.o:(.bss+0x0): multiple definition of `THREAD_NUM'; src/esthmm.o:(.bss+0x0): first defined here
/cm/shared/easybuild/software/binutils/2.38-GCCcore-11.3.0/bin/ld: src/viterbi.o:(.bss+0x4): multiple definition of `MAXITERATION'; src/esthmm.o:(.bss+0x4): first defined here
/cm/shared/easybuild/software/binutils/2.38-GCCcore-11.3.0/bin/ld: src/fileutils.o:(.bss+0x0): multiple definition of `THREAD_NUM'; src/esthmm.o:(.bss+0x0): first defined here
/cm/shared/easybuild/software/binutils/2.38-GCCcore-11.3.0/bin/ld: src/fileutils.o:(.bss+0x4): multiple definition of `MAXITERATION'; src/esthmm.o:(.bss+0x4): first defined here
collect2: error: ld returned 1 exit status
make: *** [Makefile:14: TRACE] Error 1

After troubleshooting and following this advice I added -fcommon to CFLAGS in the Makefile and that fixed it. Not sure if that will cause other problems down the road but I thought I'd post here in case anyone else has the same problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions