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

x/mobile: stdlibc++ deprecation building issue: flags set but still shows error: clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of iOS 7 [-Wdeprecated] #29969

Closed
imWildCat opened this issue Jan 29, 2019 · 4 comments
Labels
FrozenDueToAge mobile Android, iOS, and x/mobile NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@imWildCat
Copy link

imWildCat commented Jan 29, 2019

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

$ go version
go version go1.11.2 darwin/amd64

Other version info:

  • Xcode: Version 10.1 (10B61)
  • macOS: 10.14.2 (18C54)

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/wildcat/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/wildcat/golang"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.11.2/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.11.2/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS="-stdlib=libc++"
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/4q/nqwtcbqx7kl9pp0dllbqx4qc0000gn/T/go-build198858859=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Background: I was trying to build a Go library (with C++ source) into objective-c bindings (as .framework).

$ export CGO_CPPFLAGS="-stdlib=libc++"
$ gomobile bind -target ios github.com/yanyiwu/gojieba
gomobile: darwin-arm: go build -tags ios -buildmode=c-archive -o /var/folders/4q/nqwtcbqx7kl9pp0dllbqx4qc0000gn/T/gomobile-work-251366135/gojieba-arm.a gobind failed: exit status 2
# github.com/yanyiwu/gojieba
clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of iOS 7 [-Wdeprecated]
ld: library not found for -lstdc++
clang: error: linker command failed with exit code 1 (use -v to see invocation)

What did you expect to see?

The library can be built as an iOS framework.

What did you see instead?

The build failed due to libstdc++ is used even if I set export CGO_CPPFLAGS="-stdlib=libc++".

Without export CGO_CPPFLAGS="-stdlib=libc++", it shows:

$ export CGO_CPPFLAGS=""
$ gomobile bind -target ios github.com/yanyiwu/gojieba
gomobile: darwin-arm: go build -tags ios -buildmode=c-archive -o /var/folders/4q/nqwtcbqx7kl9pp0dllbqx4qc0000gn/T/gomobile-work-275429029/gojieba-arm.a gobind failed: exit status 2
# github.com/yanyiwu/gojieba
warning: include path for stdlibc++ headers not found; pass '-std=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
In file included from jieba.cpp:5:
In file included from ../../../../golang/src/github.com/yanyiwu/gojieba/deps/cppjieba/Jieba.hpp:4:
../../../../golang/src/github.com/yanyiwu/gojieba/deps/cppjieba/QuerySegment.hpp:4:10: fatal error: 'algorithm' file not found
@gopherbot gopherbot added this to the Unreleased milestone Jan 29, 2019
@gopherbot gopherbot added the mobile Android, iOS, and x/mobile label Jan 29, 2019
@bcmills
Copy link
Contributor

bcmills commented Mar 1, 2019

CC @eliasnaur @hyangah

@bcmills bcmills added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Mar 1, 2019
@gopherbot
Copy link

Change https://golang.org/cl/164800 mentions this issue: cmd/gomobile: bump default iOS minimum version to 7.0

@eliasnaur
Copy link
Contributor

@imWildCat you can use the latest version of gomobile or the -iosversion flag to set a minimum iOS version >= 7.

@imWildCat
Copy link
Author

Thank you, @eliasnaur ! It works perfectly!

@golang golang locked and limited conversation to collaborators Mar 1, 2020
imWildCat pushed a commit to imWildCat/go-mobile that referenced this issue Apr 10, 2021
Recent Xcode versions are unable to build C++ files if the minimum
iOS version is below 7.0. Bump the default version to 7.0; it is
ancient and users can override it with -iosversion.

Fixes golang/go#29969

Change-Id: I4e35e021e0fa10c1681df1073efa73700c3aae69
Reviewed-on: https://go-review.googlesource.com/c/164800
Run-TryBot: Elias Naur <mail@eliasnaur.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
imWildCat pushed a commit to imWildCat/go-mobile that referenced this issue Apr 11, 2021
Recent Xcode versions are unable to build C++ files if the minimum
iOS version is below 7.0. Bump the default version to 7.0; it is
ancient and users can override it with -iosversion.

Fixes golang/go#29969

Change-Id: I4e35e021e0fa10c1681df1073efa73700c3aae69
Reviewed-on: https://go-review.googlesource.com/c/164800
Run-TryBot: Elias Naur <mail@eliasnaur.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge mobile Android, iOS, and x/mobile NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants