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

Build error after adding support of Avif files on Linux #44

Open
mczachurski opened this issue Aug 23, 2024 · 1 comment
Open

Build error after adding support of Avif files on Linux #44

mczachurski opened this issue Aug 23, 2024 · 1 comment

Comments

@mczachurski
Copy link
Contributor

After merging PR #42 there is an error during build on Ubuntu Docker (in Vapor application). Seems like there is missing something in Linux connected with gdImageCreateFromAvifPtr.

#18 94.04 /build/.build/checkouts/SwiftGD/Sources/SwiftGD/Format.swift:225:88: error: cannot find 'gdImageCreateFromAvifPtr' in scope
#18 94.04      fileprivate let importFunction: (Int32, UnsafeMutableRawPointer) -> gdImagePtr? = gdImageCreateFromAvifPtr
#18 94.04                                                                                        ^~~~~~~~~~~~~~~~~~~~~~~~
#18 94.04 /build/.build/checkouts/SwiftGD/Sources/SwiftGD/Format.swift:228:110: error: cannot find 'gdImageAvifPtr' in scope
#18 94.04      fileprivate let exportFunction: (gdImagePtr, UnsafeMutablePointer<Int32>) -> UnsafeMutableRawPointer? = gdImageAvifPtr
#18 94.04                                                                                                              ^~~~~~~~~~~~~~
#18 94.04 error: fatalError
#18 ERROR: process "/bin/sh -c swift build -c release --static-swift-stdlib" did not complete successfully: exit code: 1
------
 > [build  7/14] RUN swift build -c release --static-swift-stdlib:
92.36 [103/1418] Compiling CVaporBcrypt blf.c
93.21 [105/1420] Compiling _NIOBase64 Base64.swift
94.04 [106/1421] Compiling SwiftGD Color.swift
94.04 /build/.build/checkouts/SwiftGD/Sources/SwiftGD/Format.swift:225:88: error: cannot find 'gdImageCreateFromAvifPtr' in scope
94.04      fileprivate let importFunction: (Int32, UnsafeMutableRawPointer) -> gdImagePtr? = gdImageCreateFromAvifPtr
94.04                                                                                        ^~~~~~~~~~~~~~~~~~~~~~~~
94.04 /build/.build/checkouts/SwiftGD/Sources/SwiftGD/Format.swift:228:110: error: cannot find 'gdImageAvifPtr' in scope
94.04      fileprivate let exportFunction: (gdImagePtr, UnsafeMutablePointer<Int32>) -> UnsafeMutableRawPointer? = gdImageAvifPtr
94.04                                                                                                              ^~~~~~~~~~~~~~
94.04 error: fatalError

My Dockerfile:

FROM swift:5.10-jammy as build

# Install OS updates and, if needed, sqlite3
RUN export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true \
    && apt-get -q update \
    && apt-get -q dist-upgrade -y \
    && apt-get install -y libgd-dev \
    && rm -rf /var/lib/apt/lists/*

# Set up a build area
WORKDIR /build

# Copy entire repo into container
COPY . .

# Clean the packages cache.
RUN swift package clean

# Build everything, with optimizations
RUN swift build -c release --static-swift-stdlib

Probably can be also reproduced on regular Ubuntu (not Docker), but I have no way to check it.

@mczachurski
Copy link
Contributor Author

The issue is that AVIF and HEIF support was added to libGD starting from version 2.3.2 (https://libgd.github.io/). This version of the library is included in Ubuntu 24.04, whereas Ubuntu 22.04 uses libGD version 2.3.0.

Therefore, it would be beneficial to update the README file to include information about this requirement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant