imagick icon indicating copy to clipboard operation
imagick copied to clipboard

Can't seem to run imagick if i compile it from M1 on Monterrey 12.1 (symbol not found in flat namespace '_AcquireAlignedMemory)

Open PolCPP opened this issue 3 years ago • 13 comments

Hi, for some reason my PHP install broke after updating to 12.1, so i had to reinstall php 8 (tried with 8.1 too), and also imagick. But for some reason even if the extension compiles correctly, once i install it and add it to the php.ini it throws me this warning and refuses to load imagick.

Warning: PHP Startup: Unable to load dynamic library 'imagick.so' (tried: /Users/polcpp/Desktop/imagick/modules/imagick.so (dlopen(/Users/polcpp/Desktop/imagick/modules/imagick.so, 0x0009): symbol not found in flat namespace '_AcquireAlignedMemory'), /Users/polcpp/Desktop/imagick/modules/imagick.so.so (dlopen(/Users/polcpp/Desktop/imagick/modules/imagick.so.so, 0x0009): tried: '/Users/polcpp/Desktop/imagick/modules/imagick.so.so' (no such file), '/usr/local/lib/imagick.so.so' (no such file), '/usr/lib/imagick.so.so' (no such file))) in Unknown on line 0

In the end i used the extension i built for the same php version on another m1 mac i had at home (using big sur) and it runs perfectly. But i don't know why the one i build on this machine doesn't work.

This is the entire log from cloning the repo, building it and running the tests http://codepad.org/bTMbOZA8

Note: I used to be able to build it and run when i got this laptop (around 2 months ago), on 12.0

PolCPP avatar Jan 03 '22 16:01 PolCPP

I would love to have an M1 to test on....looking at the compile warnings, there's a couple that are actually potentially problematic. Particularly the wrong size ones.

I suggest trying:

  1. Running the command ldconfig /usr/local/lib or wherever the imagemagick libraries like libMagickCore-7.Q16HDRI.so.9 live

  2. Recompiling ImageMagick. The symbol it can't find '_AcquireAlignedMemory' is part of the underlying ImageMagick library, not Imagick. After that rebuild Imagick again.

  3. Reinstall xcode and recompile after that. There's possibly some directory shenigans going on.

Danack avatar Jan 03 '22 16:01 Danack

Hello,

I have exactly the same problem. Tried everything for two days but no result.

OS: Monterey 12.3.1 M1 Air PEAR Version: 1.10.13 PHP Version: 7.4.27 Zend Engine Version: 3.4.0 Apple clang version: 13.1.6 (clang-1316.0.21.2.3) Target: x86_64-apple-darwin21.4.0 and arm64-apple-darwin21.4.0 Thread model: posix

  • Before compile, I changed the arch from arm to x86_64, didn't work.
  • imagemagick 7 (brew) with imagick 3.7.0, didn't work.
  • imagemagick 6 (brew) with imagick 3.4.4, didn't work.

I always got the same error: (0x0009): symbol not found in flat namespace '_AcquireAlignedMemory'

I hope, this information helps to fix the problem as soon as possible.

Thanks.

mustafa519 avatar May 16 '22 18:05 mustafa519

I had the exact same issue trying to compile it using x86_64 PHP 8.1 binaries. Changing the arch didn't help. Using arm64 binaries to compile Imagick worked.

Naroh091 avatar Jun 01 '22 17:06 Naroh091

I had the exact same issue trying to compile it using x86_64 PHP 8.1 binaries. Changing the arch didn't help. Using arm64 binaries to compile Imagick worked.

I still don't know how to fix it? My other libs are x86_64. So I have to compile it in x86_64. Maybe it would work if I could find out x86_64 compiled version that I could download somewhere (for my PHP version)?

Please let me fix this, I have no any clue other than this issue on internet. So I really need help to work out the library on my projects.

mustafa519 avatar Jun 02 '22 17:06 mustafa519

IIRC i ended giving up and then proceeded to pick up the binary from my other laptop that had it compiled on Mac os 11 (for php 8.0)

I uploaded it on onedrive in case someone is in dire need of it. It's been working for me (but as always don't trust binaries of random strangers yada yada)

https://1drv.ms/u/s!Avm1M_VdmICFt1xw84attVKJ_CAa?e=9VmBjV

I had it here: /opt/homebrew/lib/php/pecl/20200930

PolCPP avatar Jun 02 '22 17:06 PolCPP

I use XAMPP PHP 7.4 x86_64 stack for now on macOS Monterey 12.3.1 M1/Arm. The stack works well in x86_64. I have installed many libraries by PECL. This library was the only one that I have issued with. I think arm builds work well, but somehow something conflicts in x86_64, on arm arch.

That binary was in arm arch and couldn't fix my issue. Do you have any plan for fixing the issue while we are compiling according to our stacks?

Thank you for the effort. And also thanks to warn about unknown binaries.

mustafa519 avatar Jun 02 '22 18:06 mustafa519

Yeah you're right, using arm-php in my case.

Tbh i forgot, been almost half a year since i fixed it in my current use-case (which doesn't fix the issue itself though). But since i saw some movement in here didn't want to be the "Denvercoder9" in this situation.

PolCPP avatar Jun 02 '22 18:06 PolCPP

Same issue here: symbol not found in flat namespace (_AcquireAlignedMemory))

eiiot avatar Sep 06 '22 02:09 eiiot

@eIiot please can you say how you're compiling Imagick.

Also, please can you confirm that you have compiled ImageMagick on that computer with the same compiler.

At least one person had a similar error message due to not doing that: "The problem was caused by mixing objects that compiled with libc++ and object that compiled with libstdc++."

Danack avatar Sep 06 '22 11:09 Danack

I really can't investigate this without info.

I would love to have an M1 to test on.

I am saving up to buy a new MBP. In lieu of providing info, if any one wants to speed up me acquiring that MBP so I can investigate myself, my sponsors page is here: https://github.com/sponsors/Danack and one-off donations would be appreciated.

Danack avatar Sep 08 '22 15:09 Danack

Having this same issue after switching to the M1

MeisamMulla avatar Sep 13 '22 00:09 MeisamMulla

I have an new M1 on the way. Please can someone post a list of instructions of how you are trying to compile Imagick, so that I can try to reproduce the error you are seeing.

Danack avatar Sep 14 '22 15:09 Danack

I was able to solve this issue.

What I had to do was uninstall any package that was installed by brew that was built for x86 that Imagick depends on and then install the corresponding arm version with brew.

I was then able to install it using pecl and everything works just fine now.

MeisamMulla avatar Sep 14 '22 16:09 MeisamMulla

Any update on this? @MeisamMulla could you tell me steps for doing so

hafizSiddiq7675 avatar Oct 26 '22 13:10 hafizSiddiq7675

It should maybe be something like:

brew uninstall imagick
brew autoremove

and then re-install.

Danack avatar Oct 26 '22 17:10 Danack

For anyone else having this problem, check if you have in /usr/local/ still some homebrew files, symlinks etc. and remove them (considering you are using an m1 macbook and have installed the arm brew version but previously used the x86 version of homebrew).

Reinstall imagemagick and the imagick extension. Specifically check if the imagick extension install process uses the right paths pointing to /opt/.... and not /usr/local/...

Pass the right path to convert (whereis convert) in the installation process for imagick extension.

Solved the issue for me!

bzelba avatar Jan 10 '23 12:01 bzelba

Yeah. @bzelba is right in the more general sense of "if you see this problem, it's probably due to a problem on your own machine, rather than something that can be fixed in Imagick".

Doing a full clean and re-install of ImageMagick and Imagick, and checking there are no errant symlinks might solve the problem.

But as there is no inherent issue to solve, I'm going to close this issue.

Danack avatar Jan 10 '23 15:01 Danack

@bzelba was right. To add more information to the matter: I migrated my Intel-based Mac to a M1-based through the Time Machine backup, so the old Intel-based installation of ImageMagick remained under /usr/local/

In order to clean it I did this:

brew uninstall --force imagemagick
cd /usr/local/bin/
ls -ial |grep -i magi
rm -f MagickWand-config animate compare composite conjure convert display identify import magick magick-script mogrify montage stream 
rm -rf ../Cellar/imagemagick
arch -arm64 brew install imagemagick
rm -rf ../Cellar/libomp
arch -arm64 brew reinstall libomp
rm -rf ../Cellar/liblqr
rm -rf ../Cellar/libtool
rm -rf ../include/libltdl 
rm -rf ../lib/libltdl*
arch -arm64 brew reinstall libtool
rm -rf /usr/local/lib/pkgconfig
rm -f /usr/local/lib/libpcre*
rm -rf /usr/local/Cellar/pcre*
arch -arm64 brew reinstall pkgconfig
arch -arm64 brew reinstall pkre
arch -arm64 brew reinstall pkre2
rm -rf /usr/local/lib/pkgconfig
rm -f /usr/local/bin/libpng
rm -f /usr/local/lib/libpng*
rm -rf /usr/local/Cellar/libpng
arch -arm64 brew reinstall libpng
arch -arm64 pecl install imagick

alexacron avatar Jan 19 '23 14:01 alexacron