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

Using cgo built DLL on Visual Studio Project #49080

Closed
ghost opened this issue Oct 20, 2021 · 1 comment
Closed

Using cgo built DLL on Visual Studio Project #49080

ghost opened this issue Oct 20, 2021 · 1 comment

Comments

@ghost
Copy link

ghost commented Oct 20, 2021

What version of Go are you using (go version)?

go version go1.15.6

Does this issue reproduce with the latest release?

I have not checked on go1.17 yet.

What operating system and processor architecture are you using (go env)?

windows/amd64

What did you do?

I want to use a golang module as c-shared library and then call it from a MFC application.

  1. I built the go module as c-shared library(example.dll) and example.h file successfully.
  2. I created simple C program, included example.h file and called my library function, I built the program with gcc command, everything worked as expected.
  3. On MFC project, included example.h file and called my library function, then used VS2019 Community to build. Error came out.
error E0020: identifier "__SIZE_TYPE__" is undefined
error E0065: expected ';'
error C2143: syntax error : missing '}' before 'enum [tag]'

I checked on Internet and found out that the problem is about compiler.
On VS2019, they use msvc as compiler for C program so when I include a cgo built library (which is using gcc by default) on VS2019 project, there are some conflicts between them.

I tried to find a way to build my golang module to c-shared library with msvc compiler and found this.
https://go-review.googlesource.com/c/go/+/133946

Unfortunately, this [cmd/compile: add support for MSVC toolchain to go build] change is still in review.

What did you expect to see?

So if there is an official guide about using cgo built library on VS2019, I would be happy.

What did you see instead?

Included in [What di you do?] section.

@ianlancetaylor
Copy link
Member

I'm sorry, using any compiler other than GCC or clang is currently unsupported.

Closing as a dup of #20982.

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

2 participants