Trying to build the following cpp/go gist sample gomobile build --target=ios/arm64 cpptest
What did you expect to see?
Successfully built package
What did you see instead?
gomobile: go build -tags ios cpptest failed: exit status 2
ld: warning: ignoring file $WORK/b001/_x003.o, file was built for x86_64 which is not the architecture being linked (arm64): $WORK/b001/_x003.o
Undefined symbols for architecture arm64:
"_hello", referenced from:
__cgo_f57df320d1c2_Cfunc_hello in _x002.o
(maybe you meant: __cgo_f57df320d1c2_Cfunc_hello)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The problem seems to be here:
as CGO_CFLAGS are set up, but no CGO_CXXFLAGS are defined. The possible workaround would be to call CGO_CXXFLAGS='-arch arm64' gomobile ... but it looks a bit cumbersome.
changed the title
Gomobile fails building package for arm64 if package contains cpp source codeSep 5, 2018