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

Issue with go get on M1 MacOS #86

Open
dtaivpp opened this issue Feb 22, 2022 · 6 comments
Open

Issue with go get on M1 MacOS #86

dtaivpp opened this issue Feb 22, 2022 · 6 comments

Comments

@dtaivpp
Copy link

dtaivpp commented Feb 22, 2022

Hey all, pretty new to go and having a problem with go get on MacOS 12.2/Go 1.17.6 on M1.

Here is what I am facing:

face-detector % go get github.com/Kagami/go-face 
# github.com/Kagami/go-face
clang: error: the clang compiler does not support '-march=native'

I am not sure if I am missing some flag that would allow this to build. Here is my go env:

face-detector % go env
GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/<username>/Library/Caches/go-build"
GOENV="/Users/<username>/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/<username>/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/<username>/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/opt/homebrew/Cellar/go/1.17.6/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/homebrew/Cellar/go/1.17.6/libexec/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.17.6"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/<username>/Development/face-detector/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/j1/gdnt9_0d3811nn7d8t63hbc80000gn/T/go-build658795374=/tmp/go-build -gno-record-gcc-switches -fno-common"

Any recommendations? I am not seeing where -march=native is set. There was a stack overflow thread that suggested using -mcpu=apple-m1 however I am not seeing where to put that.

@gougo
Copy link

gougo commented Jun 7, 2022

modify face.go at this project

package face

// #cgo CXXFLAGS: -std=c++1z -Wall -O3 -DNDEBUG -mcpu=apple-m1

@nodoyuna
Copy link

nodoyuna commented Jan 11, 2023

another solutions is update clang with brew

lang: error: the clang compiler does not support '-march=native'

1° - Install llvm con brew
brew install llvm
2° - Check clang version

cd /opt/homebrew/opt/llvm
.clang --version

Result:

Homebrew clang version 15.0.6
Target: arm64-apple-darwin22.2.0
Thread model: posix
InstalledDir: /opt/homebrew/opt/llvm/bin

3° - modify path with the new version, for example add to .zshrc
export PATH="/opt/homebrew/opt/llvm/bin:$PATH"

@Exegetech
Copy link

I tried the solution above, and now it gets an error

classify.cc:2:10: fatal error: 'dlib/graph_utils.h' file not found

@chaosue
Copy link

chaosue commented Jul 16, 2023

I tried the solution above, and now it gets an error

classify.cc:2:10: fatal error: 'dlib/graph_utils.h' file not found

try
CPLUS_INCLUDE_PATH=/opt/homebrew/Cellar/jpeg/9d/include/:/opt/homebrew/Cellar/dlib/19.24_1/include LD_LIBRARY_PATH=/opt/homebrew/Cellar/dlib/19.24_1/lib/:/opt/homebrew/Cellar/jpeg/9d/lib/ LIBRARY_PATH=/opt/homebrew/Cellar/dlib/19.24_1/lib/:/opt/homebrew/Cellar/jpeg/9d/lib/ go build

@adrien3d
Copy link

Same error here, even with setting LIBRARY_PATH (for me, CPLUS_INCLUDE_PATH and LD_LIBRARY_PATH were already setup correctly).
Any hints @chaosue @Kagami @gougo @Exegetech @nodoyuna @dtaivpp ?

@adrien3d
Copy link

Fixed by copying dlib in $GOPATH/pkg/path/to/go-faceand changing import in classify.cc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants