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

Unable to compile gen2brain/go-fitz library with GOOS and GOARCH #12166

Open
anandsoni11 opened this issue Jul 19, 2022 · 1 comment
Open

Unable to compile gen2brain/go-fitz library with GOOS and GOARCH #12166

anandsoni11 opened this issue Jul 19, 2022 · 1 comment
Labels
bug Observed behavior contradicts documented or intended behavior zig cc Zig as a drop-in C compiler feature
Milestone

Comments

@anandsoni11
Copy link

anandsoni11 commented Jul 19, 2022

Hi, I am using zig to cross compile a go module (go-fitz) on my Mac. The compiler options used are as below :

GOOS=linux GOARCH=amd64 CGO_ENABLED=1 CC="zig cc -target x86_64-linux" CXX="zig c++ -target x86_64-linux" go build -o main *.go

But, I am getting the below error on compilation -

/usr/local/Cellar/go/1.18/libexec/pkg/tool/darwin_amd64/link: running zig failed: exit status 1
ld.lld: error: undefined symbol: __fprintf_chk
>>> referenced by context.c
>>>               context.o:(fz_new_context_imp) in archive /Users/user1/go/pkg/mod/github.com/gen2brain/go-fitz@v1.18.0/libs/libmupdf_linux_amd64.a
>>> referenced by error.c
>>>               error.o:(fz_default_error_callback) in archive /Users/user1/go/pkg/mod/github.com/gen2brain/go-fitz@v1.18.0/libs/libmupdf_linux_amd64.a
>>> referenced by error.c
>>>               error.o:(fz_default_warning_callback) in archive /Users/user1/go/pkg/mod/github.com/gen2brain/go-fitz@v1.18.0/libs/libmupdf_linux_amd64.a
>>> referenced 39 more times

On the other hand, if I use the below options, the compilation runs successfully but I get a segmentation fault at runtime :
GOOS=linux GOARCH=amd64 CGO_ENABLED=1 CC="zig cc -target x86_64-linux-gnu" go build -o main *.go
Can you please help me here? Thank you!

@Vexu Vexu added bug Observed behavior contradicts documented or intended behavior zig cc Zig as a drop-in C compiler feature labels Jul 29, 2022
@Vexu Vexu added this to the 0.12.0 milestone Jul 29, 2022
@kassane
Copy link
Contributor

kassane commented Sep 4, 2022

Have you tried adding the flag -lc on cc and -lc++ on cxx?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior zig cc Zig as a drop-in C compiler feature
Projects
None yet
Development

No branches or pull requests

3 participants