Fix `ld: library not found for -lgomp` when installing Imagick 3.5 via PHP pecl on Mac

Update 25 July 2021

As of 22 July 2021, version 3.5.1 is stable in the pecl channel and can be used to compile imagick for both PHP 7 and PHP 8.

pecl install imagick

The general command will not fail anymore


Install the older version (3.4.4) of Imagick forcing it via `pecl`

pecl install imagick-3.4.4


The last version (3.5) of the PHP extension for Imagemagick ( Imagick ) introduces a compilation error on Apple systems, which is independent from the PHP version (tested on 7.4 and 8) and Imagemagick version (tested on 6.x and 7.x) and is instead related to the missing/broken support for gomp of the gcc compiler.

This is not related to Apple Silicon either, as I’ve tested on an Intel machine.


The error is thrown while compiling, after running

pecl install imagick

The complete error is

ld: library not found for -lgomp

Potential Fixes

There are several Stack Overflow threads talking about compilation errors due to Gomp. The most comprehensive I’ve found is this.

I’ve tried few of the fixes proposed in the answer, but most require compiling a different version of gcc, which would make subsequent updates via homebrew unstable.

Also tried this other amazing thread on Stack Overflow which suggests `llvm` and revised compiler flags, but it didn’t work for this specific case, probably due to built-in parameters in the pecl compilation process.

Actual Fix

In the end the final fix was to downgrade the version of Imagick to 4.3.3, which compiles perfectly.

You can do so either by downloading the release from github or simply by forcing the version in pecl as follows:

pecl install imagick-3.4.4




Co-founder @Lnk.Bio — Developing stuff on the Web since 2003

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

VSCode for Green Screen Developers

How to collect data from Statistics Canada using Python

2020 Top Slack Channels for Software Testers

Important Announcement: Servers, PC/Mobile Wallets

GUI based Application inside DOCKER Container !!

A very quick Intro to React

Deploying a Spring Boot REST API on Azure Kubernetes Service with Azure Database for PostgreSQL

A Short Note on Distributed System

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Andrea Olivato

Andrea Olivato

Co-founder @Lnk.Bio — Developing stuff on the Web since 2003

More from Medium

Using Database Transactions in Laravel

Laravel Authentication using Web3

Running Laravel Queue:work in cPanel

Create A Simple PHP Server Using VSCode Tasks

Cover image for Create A Simple PHP Server Using VSCode Tasks