Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/cgo: duplicate symbol "stat" #7542

Closed
mitchellh opened this issue Mar 14, 2014 · 11 comments

Comments

@mitchellh
Copy link

commented Mar 14, 2014

With a minimal project, I get this cgo error on Windows with msys:

main.go:

    package main

    import "C"

test.c:

    #include <sys/stat.h>

    void check() {
      struct stat st;
      stat("/tmp/foo", &st);
    }

Runing "go build":

C:\Users\Mitchell\AppData\Local\Temp\go-build746675543\_\C_\Users\Mitchell\AppData\Local\Temp\gotest.a(_all.o):
duplicate symbol reference: stat in both main(.text) and main(.data)

Go version: 

go version devel +4df290191840 Wed Jan 15 09:50:55 2014 -0800 windows/amd64
@mitchellh

This comment has been minimized.

Copy link
Author

commented Mar 14, 2014

Comment 1:

I just tested and this issue exists with go 1.2.1 as well.
@mitchellh

This comment has been minimized.

Copy link
Author

commented Mar 14, 2014

Comment 2:

I can also confirm that this behavior does _not_ exist on Mac OS X.
@mitchellh

This comment has been minimized.

Copy link
Author

commented Mar 17, 2014

Comment 3:

A little more research and I noticed this is only with 64-bit msys, as setup according
to this: https://code.google.com/p/go-wiki/wiki/WindowsBuild
@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented May 9, 2014

Comment 4:

Labels changed: added repo-main, release-go1.4, os-windows.

@rsc

This comment has been minimized.

Copy link
Contributor

commented Sep 24, 2014

Comment 5:

Labels changed: added release-go1.4maybe, removed release-go1.4.

Status changed to Accepted.

@alexbrainman

This comment has been minimized.

Copy link
Member

commented Sep 25, 2014

Comment 6:

Strangely, it works fine on windows/386:
C:\go\path\src\issue7542>go build
# issue7542
runtime.main_main: main.main: not defined
runtime.main_main: undefined: main.main
Alex
@mitchellh

This comment has been minimized.

Copy link
Author

commented Sep 25, 2014

Comment 7:

Alex, that is correct. I should've explained that this is working fine on 386. It also
works fine on amd64 if you have the 386 toolchain compiled. It only fails if you have
the 64-bit MinGW toolchain compiled to build amd64 binaries.
@rsc

This comment has been minimized.

Copy link
Contributor

commented Oct 28, 2014

Comment 8:

Labels changed: added release-go1.5, removed release-go1.4maybe.

@alexbrainman

This comment has been minimized.

Copy link
Member

commented Apr 2, 2015

I believe this is fixed now by latest @minux cmd/ld pe changes.

@mattn

This comment has been minimized.

Copy link
Member

commented Apr 2, 2015

i had just made sure the code above is compilable in tip.

@minux

This comment has been minimized.

Copy link
Member

commented Apr 2, 2015

@golang golang locked and limited conversation to collaborators Jun 25, 2016

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
8 participants
You can’t perform that action at this time.