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
Closed

cmd/cgo: duplicate symbol "stat" #7542

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

Comments

@mitchellh
Copy link

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
Copy link
Author

Comment 1:

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

@mitchellh
Copy link
Author

Comment 2:

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

@mitchellh
Copy link
Author

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
Copy link
Contributor

Comment 4:

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

@rsc
Copy link
Contributor

rsc commented Sep 24, 2014

Comment 5:

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

Status changed to Accepted.

@alexbrainman
Copy link
Member

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
Copy link
Author

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
Copy link
Contributor

rsc commented Oct 28, 2014

Comment 8:

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

@alexbrainman
Copy link
Member

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

@mattn
Copy link
Member

mattn commented Apr 2, 2015

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

@minux
Copy link
Member

minux commented Apr 2, 2015 via email

@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
Development

No branches or pull requests

8 participants