Skip to content

Compilation Error with go-fitz and Homebrew-installed MuPDF due to Type Mismatch #143

@hiyced

Description

@hiyced

I am encountering a compilation error when trying to build a Go project that depends on github.com/gen2brain/go-fitz (v1.24.15). The error occurs specifically when linking against the MuPDF library installed via Homebrew (version 1.26.10).

Error Message:
# github.com/gen2brain/go-fitz ../../../../pkg/mod/github.com/gen2brain/go-fitz@v1.24.15/fitz_cgo.go:546:103: cannot use _Ctype_int(len(buf)) (value of int32 type _Ctype_int) as _Ctype_size_t value in variable declaration

Environment Details:

  • Local MuPDF Version: 1.26.10 (installed via Homebrew)
  • go-fitz Version: v1.24.15
  • System: macOS 15.6.1

Analysis:
The error indicates a type mismatch in the CGo code of go-fitz. The code is trying to assign a value of type _Ctype_int (which is an int32 in this context) to a variable expecting _Ctype_size_t (typically size_t, an unsigned type whose size may vary by platform). This suggests a potential incompatibility between the expected types in the go-fitz wrapper and the actual types used by the MuPDF library installed via Homebrew.

Possible Causes:

  1. The Homebrew version of MuPDF (1.26.10) may have introduced changes in type definitions or API signatures that are not yet handled by the current version of go-fitz.
  2. The go-fitz wrapper may not fully support the latest MuPDF version, as it was likely tested against an older version of MuPDF.
  3. There might be platform-specific differences in type sizes (e.g., size_t vs. int) between the environment where go-fitz was developed and the Homebrew build of MuPDF.

Request:
I would appreciate guidance on how to resolve this compilation issue. Possible solutions could include:

  • Updating go-fitz to a newer version compatible with MuPDF 1.26.10.
  • Modifying the go-fitz CGo code to handle the type mismatch appropriately.
  • Using a specific version of MuPDF that is known to work with go-fitz v1.24.15.

Thank you for your support!


Let me know if you need further adjustments

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions