Skip to content
This repository was archived by the owner on Dec 8, 2022. It is now read-only.
This repository was archived by the owner on Dec 8, 2022. It is now read-only.

Multiple definitions of functions during executable generation #247

@samhorsfield96

Description

@samhorsfield96

Hi,

I'm following the "Calling Seq from C/C++" example using the latest seq-lang release (v0.11.0) and generate a shared object, but when linking to the executable I get the following errors:

$ seqc build -o foo.o foo.seq
$ gcc -shared -L/path/to/seq/lib -o libfoo.so foo.o -no-pie -lseqrt -lomp
$ gcc -o foo -lfoo foo.c
foo.c: In function ‘int main()’:
foo.c:7:27: warning: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 2 has type ‘int64_t {aka long int}’ [-Wformat=]
   printf("%llu\n", foo(10));
                    ~~~~~~~^
./libfoo.so: In function `_start':
(.text+0x0): multiple definition of `_start'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/Scrt1.o:(.text+0x0): first defined here
./libfoo.so: In function `_fini':
(.fini+0x0): multiple definition of `_fini'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/crti.o:(.fini+0x0): first defined here
./libfoo.so:(.rodata+0x0): multiple definition of `_IO_stdin_used'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/Scrt1.o:(.rodata.cst4+0x0): first defined here
./libfoo.so: In function `data_start':
(.data+0x0): multiple definition of `__data_start'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/Scrt1.o:(.data+0x0): first defined here
./libfoo.so: In function `data_start':
(.data+0x8): multiple definition of `__dso_handle'
/usr/lib/gcc/x86_64-linux-gnu/7/crtbeginS.o:(.data.rel.local+0x0): first defined here
./libfoo.so: In function `_init':
(.init+0x0): multiple definition of `_init'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/crti.o:(.init+0x0): first defined here
/tmp/ccre1xzA.o: In function `main':
foo.c:(.text+0x0): multiple definition of `main'
./libfoo.so:/Users/seq-lang-test/foo.seq:(.text+0x1160): first defined here
/usr/lib/gcc/x86_64-linux-gnu/7/crtendS.o:(.tm_clone_table+0x0): multiple definition of `__TMC_END__'
./libfoo.so:(.data+0x10): first defined here
/usr/bin/ld: error in ./libfoo.so(.eh_frame); no .eh_frame_hdr table will be created.
/tmp/ccre1xzA.o: In function `main':
foo.c:(.text+0xa): undefined reference to `foo(long)'
collect2: error: ld returned 1 exit status

Calling ldd on the shared object file gives me

$ ldd libfoo.so
        linux-vdso.so.1 (0x00007fffc485a000)
        libseqrt.so => /path/to/seq/lib/libseqrt.so (0x00007fc603ce0000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fc6038d0000)
        libomp.so => /path/to/seq/lib/libomp.so (0x00007fc603809000)
        librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fc603600000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fc6033f0000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fc6031d0000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fc602e20000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fc602c00000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fc604400000)

Would you be able to help with this if possible, please? I'm running this using Ubuntu 18.04 via WSL with gcc v 7.5.0 just for reference.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions