ethereum / go-ethereum

Go implementation of the Ethereum protocol
https://geth.ethereum.org
GNU Lesser General Public License v3.0
47.06k stars 19.94k forks source link

go build release/1.9 failed: fatal error: 'CoreServices/CoreServices.h' IOTypes.h file not found in mac 10.15.6 #21835

Closed huahuayu closed 3 years ago

huahuayu commented 3 years ago

System information

I got a new mac three days ago, Macbook pro 2020

OSX 10.15.6

I install brew, which I see the log, it will install xcode

And then I install xcode from appstore as well, open it, accept the terms and install more packages.

Expected behaviour

I expected: go build will success

cd go-ethereum
git checkout release/1.9
go build ./...

Actual behaviour

go build failed as below

$ go build ./...
go: downloading github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa
# github.com/rjeczalik/notify
../go/pkg/mod/github.com/rjeczalik/notify@v0.9.1/watcher_fsevents_cgo.go:10:10: fatal error: 'CoreServices/CoreServices.h' file not found
#include <CoreServices/CoreServices.h>
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../go/pkg/mod/github.com/rjeczalik/notify@v0.9.1/watcher_fsevents_cgo.go:10:10: note: did not find header 'CoreServices.h' in framework 'CoreServices' (loaded from '/System/Library/Frameworks')
1 error generated.
# gopkg.in/olebedev/go-duktape.v3
In file included from _cgo_export.c:4:
debugger.go:23:13: warning: unused function '_duk_debugger_attach' [-Wunused-function]
# github.com/karalabe/usb
In file included from ../go/pkg/mod/github.com/karalabe/usb@v0.0.0-20190919080040-51dc0efba356/libs.go:50:
In file included from ../go/pkg/mod/github.com/karalabe/usb@v0.0.0-20190919080040-51dc0efba356/libusb/libusb/os/darwin_usb.c:72:
../go/pkg/mod/github.com/karalabe/usb@v0.0.0-20190919080040-51dc0efba356/libusb/libusb/os/darwin_usb.h:25:10: fatal error: 'IOKit/IOTypes.h' file not found
#include <IOKit/IOTypes.h>
         ^~~~~~~~~~~~~~~~~
../go/pkg/mod/github.com/karalabe/usb@v0.0.0-20190919080040-51dc0efba356/libusb/libusb/os/darwin_usb.h:25:10: note: did not find header 'IOTypes.h' in framework 'IOKit' (loaded from '/System/Library/Frameworks')
1 error generated.

Things I have done

  1. xcode-select --install is useless
$ xcode-select --install

xcode-select: error: command line tools are already installed, use "Software Update" to install updates
  1. I have searched the issues, some similar issue is as below, without lucky

  2. I googled

  3. I know the missing headers file location in mac

I use find cmd to search the diskfind /Library/Developer -name CoreServices.h, so I know the CoreServices.h is at /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/CoreServices.framework/Versions/A/Headers

then I symbolic linked them to /usr/local/include/, but no use

sudo ln -s /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/CoreServices.framework/Versions/A/Headers/* /usr/local/include/

If anyone can help?

Related issue

Besides CoreServices/CoreServices.h, Also, there's another header file issue from the log

fatal error: 'IOKit/IOTypes.h' file not found
hadv commented 3 years ago

@huahuayu take a look on installation guide. Basically, you can use makefile to build geth source code

https://github.com/ethereum/go-ethereum/wiki/Installation-Instructions-for-Mac

huahuayu commented 3 years ago

@hadv What I am doing is not to build geth source code, I am developing service interactive smart contract with go, when build the project, the same issue as build ethereum-go project, so raise an issue here

huahuayu commented 3 years ago

dear @karalabe @rjl493456442 , could you please help to check

huahuayu commented 3 years ago

@fjl hi, thank you for help to look the issue, can you reproduce? If you need any additional info, please let me know. This issue drive me crazy, currently, my workaround is to develop inside a Ubuntu VM.

hadv commented 3 years ago

@huahuayu FYI: I have no error when building go-ethereum v1.9.24 with below env

  1. MacOS Big Sur v11.0.1
  2. go1.15.5 darwin/amd64
huahuayu commented 3 years ago

@hadv thx, i am installing macos 11 now, 10 mins left I think, I will check

huahuayu commented 3 years ago

I upgrade to macos 11, the issue is still there @hadv

$ go build ./...
# gopkg.in/olebedev/go-duktape.v3
In file included from _cgo_export.c:4:
debugger.go:23:13: warning: unused function '_duk_debugger_attach' [-Wunused-function]
# github.com/rjeczalik/notify
../go/pkg/mod/github.com/rjeczalik/notify@v0.9.1/watcher_fsevents_cgo.go:10:10: fatal error: 'CoreServices/CoreServices.h' file not found
#include <CoreServices/CoreServices.h>
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../go/pkg/mod/github.com/rjeczalik/notify@v0.9.1/watcher_fsevents_cgo.go:10:10: note: did not find header 'CoreServices.h' in framework 'CoreServices' (loaded from '/System/Library/Frameworks')
1 error generated.
hadv commented 3 years ago

@huahuayu try to run sudo xcode-select --reset then rebuild

huahuayu commented 3 years ago

hi, @hadv it's no use image

nklipa13 commented 3 years ago

I'm having the same issue and I'm unable to install abigen. MacOS version is Catalina 10.15.7. Is there any workaround or maybe other way to install abigen?

slika
MariusVanDerWijden commented 3 years ago

@nklipa13 You can download geth and tools from our download page: https://geth.ethereum.org/downloads/

fjl commented 3 years ago

@nklipa13 the message in your screenshot is just a warning

huahuayu commented 3 years ago

@nklipa13 You can download geth and tools from our download page: https://geth.ethereum.org/downloads/

but what I need is to debug and compile in code, not the binary

mr-ma commented 3 years ago

I am experiencing the same problem as @huahuayu on Mac OS Catalina:

In file included from _cgo_export.c:4:
debugger.go:23:13: warning: unused function '_duk_debugger_attach' [-Wunused-function]
karalabe commented 3 years ago

@mr-ma That's a warning, not an error

huahuayu commented 3 years ago

Dear all, I had enough of the cgo problem, I reinstall my macOS(11.2.3), and my first thing to do is to verify the go installation and go-ethereum compile. And it works, but I don't know why.

Try not to use your previews go env setting, delete them all. If it doesn't work, reinstall mac system can save you.

fjl commented 3 years ago

Thanks for the update! Good to hear it is finally resolved for you now!

zhangwenhua-tron commented 3 years ago

I have upgrade my system to Big Sur 11.4, and I found the errors:

$ make geth env GO111MODULE=on go run build/ci.go install ./cmd/geth

runtime/cgo

ld: library not found for -lpthread clang-4.0: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [geth] Error 2

fjl commented 3 years ago

@zhangwenhua-tron please try running sudo xcode-select --install to install the Xcode command-line tools.

peterwillcn commented 2 years ago

any news?