prost icon indicating copy to clipboard operation
prost copied to clipboard

Error when cross compiling using `cross build`

Open Danvil opened this issue 1 year ago • 7 comments

When cross-compiling a program using prost with cross I get the following error:

 Error: Custom { kind: Other, error: "protoc failed: " }

Host: Windows Target: aarch64-unknown-linux-gnu Cross configured to use podman

Danvil avatar Oct 01 '23 19:10 Danvil

Hi @Danvil , Can you share your Cross.toml?

I am able to using Cross and Prost and cross compile to various architectures. Here's a link to Cross.toml from one of my repo.

crazystylus avatar Oct 02 '23 15:10 crazystylus

Thank you that reference helped!

I added "apt install -y protobuf-compiler", to my Cross.toml, but now I get this error:

Error: Custom { kind: Other, error: "protoc failed: foo.proto:5:10: Unrecognized syntax identifier \"proto3\". This parser only recognizes \"proto2\".\n" }

Full Cross.toml:

[target.aarch64-unknown-linux-gnu]
pre-build = [
    "dpkg --add-architecture $CROSS_DEB_ARCH",
    "apt-get update && apt-get install -y pkg-config libudev-dev:$CROSS_DEB_ARCH",
    "apt install -y protobuf-compiler",
]

Danvil avatar Oct 02 '23 18:10 Danvil

It looks like an old version of protobuff-compiler is being installed. Can you also try adding image name similar to the cross.toml from pervious comment? Adding the image name will ensure that you are using latest version of container image.

On Tue, Oct 3, 2023, 00:27 David Weikersdorfer @.***> wrote:

Thank you that reference helped!

I added "apt install -y protobuf-compiler", to my Cross.toml, but now I get this error:

Error: Custom { kind: Other, error: "protoc failed: foo.proto:5:10: Unrecognized syntax identifier "proto3". This parser only recognizes "proto2".\n" }

Full Cross.toml:

[target.aarch64-unknown-linux-gnu] pre-build = [ "dpkg --add-architecture $CROSS_DEB_ARCH", "apt-get update && apt-get install -y pkg-config libudev-dev:$CROSS_DEB_ARCH", "apt install -y protobuf-compiler", ]

— Reply to this email directly, view it on GitHub https://github.com/tokio-rs/prost/issues/929#issuecomment-1743588336, or unsubscribe https://github.com/notifications/unsubscribe-auth/AG5IY33UIOCFFAUNFFEANXLX5MFA3AVCNFSM6AAAAAA5OQU522VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONBTGU4DQMZTGY . You are receiving this because you commented.Message ID: @.***>

crazystylus avatar Oct 02 '23 19:10 crazystylus

"main" seems to provide a newer version of protobuf, but unfortunately it is still too old. My protos use optional and need at least v3.15 (version from early 2021). I guess this issue is not directly related to prost though. I will play around with the cross setup to maybe manually download a newer version.

Danvil avatar Oct 02 '23 23:10 Danvil

@Danvil Has this been resolved? Can you share the solution and close this issue?

caspermeijn avatar Feb 13 '24 09:02 caspermeijn

@caspermeijn I resolved the issue but unfortunately I don't quite remember exactly how.

I did add this line to my Cross.toml:

image = "ghcr.io/cross-rs/aarch64-unknown-linux-gnu:main"

Manually specifying an image might have pulled a newer version of the protobuf compiler.

Danvil avatar Feb 14 '24 20:02 Danvil

@Danvil Could you close the issue, now that it is resolved?

caspermeijn avatar Feb 19 '24 16:02 caspermeijn