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: Does gomobile does not support static link through cgo? #70656

Closed
ZionDoki opened this issue Dec 3, 2024 · 1 comment
Closed

x/mobile: Does gomobile does not support static link through cgo? #70656

ZionDoki opened this issue Dec 3, 2024 · 1 comment
Labels
mobile Android, iOS, and x/mobile
Milestone

Comments

@ZionDoki
Copy link

ZionDoki commented Dec 3, 2024

FOR HELP:

When I try to wrap a C/C++ static library with CGO, I found that the .a file does not build into an xcframework. I must add the .a files to my project, otherwise Xcode will throw errors such as "undefined symbols."

My Golang version is 1.23.

Usage examples:

  1. https://github.com/mysteriumnetwork/go-openvpn/blob/master/openvpn3/session.go#L24-L45
  2. https://github.com/mysteriumnetwork/go-openvpn/blob/master/gomobile_ios.sh

The first link demonstrates using CGO to wrap .a files.
The second link shows the build command.

There are no issues during the build phase, but when you try to use the output xcframework, the IDE will report missing symbols. The common solution is to add the .a files to the Xcode project.

Is there any CFLAG or other build parameter that could make the .a files statically link into the xcframework?

@gopherbot gopherbot added the mobile Android, iOS, and x/mobile label Dec 3, 2024
@gopherbot gopherbot added this to the Unreleased milestone Dec 3, 2024
@ZionDoki ZionDoki closed this as completed Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mobile Android, iOS, and x/mobile
Projects
None yet
Development

No branches or pull requests

3 participants