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
runtime/cgo: fails to build after updating to Mojave #27921
Comments
What, precisely, did you do? |
The error certainly looks like a problem with your xcode installation. It looks like your C compiler can not find the standard header files. |
such errors, thx. runtime/cgo_cgo_export.c:3:10: fatal error: 'stdlib.h' file not found $ sudo rm -rf /Library/Developer/CommandLineTools But the error does not go away. TT |
What happens if you put this code into a file named hello.c and run #include <stdlib.h>
int main() { exit(0); } |
done. |
OK, you need to fix that problem somehow. That is a problem with your C compiler. It is not a problem with Go. There is nothing that we can change in the Go tools to fix that. Unfortunately I have no idea what the problem is. I'm going to close this issue since there is nothing we can do. Please comment if you disagree. |
Me too @Elixworks |
You can try |
I have the same issue and |
Found the solution with this one |
|
@mimoo, you saved my day, thanks :) |
worked for me |
This does the magic. |
xcode-select --install worked for me |
I was seeing the same issue but that was due to GCC, which I install using |
FYI - Had the same issue, tried everything above However, the file, mentioned in comments above...
seems to be no longer available, with the latest version of xcode, see the New Features section here Solution:Running
So, using the script provided in the link below, which simply moves the files one at a time to another folder, fixed the issue for me Repeated below...
|
Nice |
on mojave 10.14.4, it works. command line> open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg |
This fix it for me! |
Unfortunately, that package appears to no longer exist as of a recent update. What can I do?
@ianlancetaylor I totally am on your side here, but unfortunately Apple has made it clear they want every project to update their build tooling to work with the weird new SDK system:
So unfortunately I think this is a bug in Go, unless you want to drop support for macOS. |
Solution: go to https://developer.apple.com/download/more/ (Apple Developer account required) and download "Command Line Tools (macOS 10.14) for Xcode 10.2.1" (or equivalent for your OS version). Extract that package, which installs the |
@raxod502 Go doesn't care where the header file is. It only cares that it can pass #include <stdlib.h> to the C compiler and have the C compiler work. If that doesn't work, there is nothing we can do in Go to fix that. |
@ianlancetaylor I understand what you are saying, but I think Apple's implication is that the Go build system needs to pass an extra It is an unfortunate fact that the C compiler cannot find An alternative solution would be for Homebrew to do something to fix this problem in general, but I don't know what the options look like for that. |
Are you saying that every Makefile for a C program needs to add a |
doesn't work in my case |
This works for me, using Catalina. |
Thanks @shalakhin! This works for me in Catalina |
This does not work for me, using Go 1.12.14. |
Removing brew llvm helped me. |
@urjitbhatia Thanks! Same issue here on Catalina. |
if someone facing this issue in catalina (10.15) |
|
Maybe this can help someone: mattn/go-sqlite3#481 (comment) |
worked like a charm! thanks |
Thanks a lot! This work for me! |
it works for me (Catalina 15.6)
|
It's all related to c compiler clang... I found the clue from the discussion above and solved my issue( I install older version clang6 pkg and leave a export in .bash_profile), all these caused by clang. So |
So I had the same/very similar issue running linux mint and this resolved the issue for me
I'm posting this here because this is the number one search result on google, so others searching will land here .. |
It works for me (Big Sur 11.1)
|
It works for me because I've used clang in anaconda. (macOS Big Sur 11.1)
|
For me on Mac OS Catalina: I found that my .zshenv "PATH=" variable, had non-standard bin paths set before the MacOS native bin path. Like so:
Simply re-ordering the PATH fixed this:
As you can see I moved /opt/pkg/{bin,sbin} to the end of the line. To find out if this is your problem: Open terminal, run: Apples clang is located in the system path /usr/bin. "bash/zsh", etc, finds commands in the order that the PATH variable is set meaning that the shell takes the first binary matching the word that it finds no matter the path it is sitting in. After you update .zshenv or .bashrc (.bash_profile), etc, run: In my case, I have brew and macports installed, but I rarely use those two because I am an avid pkgsrc user. So /opt/pkg/bin was set by me when I deployed Joyents pkgsrc bootstrap. Therefore changing my path order, In my case at least, can break other pkg's that I have installed that I want prioritised over Apples. I tried to resolve this by running |
This fixed my issue. The path for Clang was coming up as |
reinstall x-code commandline tools :
and then
it work for me ! |
clang的版本问题,我修改为xcode的clang |
set Environment Varibles in xcode clang target arguments: SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk worked for me! |
@ianlancetaylor wrote:
Apple says:
Notice this part:
Is there really nothing that can be done in the Go tools to fix this issue? |
Yes, there is really nothing that can be done in the Go tools. The Go tools never read system headers themselves, and they never read /usr/include. Instead, they invoke the C compiler, and expect the C compiler to read those headers. You can see the C compiler that they will invoke by using |
Got it. Thanks for the reply :) |
Thanks a lot! This work for me! |
thanks |
What version of Go are you using (
go version
)?GCC
What did you do?
update macOS to mojave,
install go, vscode for Developement.
An error that did not get offended when go test was done within an existing project occurred. It is below.
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
What is missing, please help me.
The text was updated successfully, but these errors were encountered: