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

go build: gives error "implicit declaration of function _beginthread" #155

Open
Monsler opened this issue Jan 29, 2025 · 2 comments
Open
Labels
troubleshooting Investigating an issue to determine its status

Comments

@Monsler
Copy link

Monsler commented Jan 29, 2025

Command:
go build -ldflags '-s -w'
Compiler: clang

Output:

# runtime/cgo
gcc_libinit_windows.c:143:13: error: implicit declaration of function '_beginthread' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
gcc_libinit_windows.c:143:13: note: did you mean '_cgo_beginthread'?
gcc_libinit_windows.c:138:6: note: '_cgo_beginthread' declared here```
@mappu mappu added the troubleshooting Investigating an issue to determine its status label Jan 30, 2025
@mappu
Copy link
Owner

mappu commented Jan 30, 2025

Some people had this problem in golang/go#59490

In that case, it was caused because the discovered CC was cygwin-gcc instead of mingw-w64 gcc.

  • If you run go env, what does it say for CC and CXX?
$ go env
[...]
CC="gcc"
CXX="g++"
  • Does it help to try this command: CC=clang CXX=clang++ go build -ldflags '-s -w'

@mappu mappu changed the title An error occurred while using go build go build: gives error "implicit declaration of function _beginthread" Jan 30, 2025
@Monsler
Copy link
Author

Monsler commented Feb 4, 2025

@mappu Hello! sorry for a late answer. As i use powershell i did it like that:

$env:CC="clang"
$enc:CXX="clang++"

After executing go env, the output is:

[...]
CC="clang"
CXX="clang++"

But when i run go build again, the error is still here.

@Monsler Monsler closed this as completed Feb 4, 2025
@Monsler Monsler reopened this Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
troubleshooting Investigating an issue to determine its status
Projects
None yet
Development

No branches or pull requests

2 participants