muscle icon indicating copy to clipboard operation
muscle copied to clipboard

Error: Library not loaded: /usr/local/opt/gcc/lib/gcc/11/libgomp.1.dylib

Open ntoex062 opened this issue 4 years ago • 16 comments

Can you help out ? I just tried to execute Muscle on a fresh MacOS installation (version 12.1; dev tools enabled).

MBP-de-Nicolas:~ nicolas$ chmod +x /Users/nicolas/Desktop/muscle
MBP-de-Nicolas:~ nicolas$ /Users/nicolas/Desktop/muscle
dyld[995]: Library not loaded: /usr/local/opt/gcc/lib/gcc/11/libgomp.1.dylib
  Referenced from: /Users/nicolas/Desktop/muscle
  Reason: tried: '/usr/local/opt/gcc/lib/gcc/11/libgomp.1.dylib' (no such file), '/usr/local/lib/libgomp.1.dylib' (no such file), '/usr/lib/libgomp.1.dylib' (no such file)
Abort trap: 6

ntoex062 avatar Jan 15 '22 14:01 ntoex062

At a guess, you need to install gcc v11 (the real gcc, not the fake gcc which is an alias for clang by default in OSX). I think you can do it using brew install gcc.

rcedgar avatar Jan 15 '22 14:01 rcedgar

Verify that it is v11 using gcc --version, if it isn't then to a web search for how do install this version specifically under Mac OSX. An alternative is to recompile following the instructions on the Wiki, see this page and scroll down to OSX: https://github.com/rcedgar/muscle/wiki/Building-MUSCLE.

rcedgar avatar Jan 15 '22 14:01 rcedgar

Thanks @rcedgar ! The gcc command made the trick !

ntoex062 avatar Jan 15 '22 15:01 ntoex062

Re-opening the issue because installing gcc-11 does not seem like a good solution. After poking around on google, it seems that there is no simple solution to creating a MacOS binary that runs on different releases of the O/S without requiring gcc installed. Under Linux, static linking has worked in muscle v3 well despite warnings against this method, but gcc on MacOS does not support this option. Suggestions solicitied!

rcedgar avatar Jan 15 '22 16:01 rcedgar

Hello, we had the same issue, and I know it's not an ideal solution, but installing muscle via conda worked for us conda install -c bioconda muscle

ros-luc avatar Mar 17 '22 11:03 ros-luc

It's a matter of using a static library, instead of /usr/local/opt/gcc/lib/gcc/11/libgomp.1.dylib to use /usr/local/opt/gcc/lib/gcc/11/libgomp.a A -static option should do the trick (perhaps -static-libstdc++). I hope.

After trying I still had trouble, but this worked:

cd src
mkdir STATIC
cd STATIC
ln -s /usr/local/opt/gcc/lib/gcc/11/*.a .
cd ..

I added -LSTATIC to two lines in the Makefile, and changed g++ to g++-11:

ifeq ($(OS),Darwin)
        CXX := g++-11
endif
 
CXXFLAGS := $(CXXFLAGS) -O3 -fopenmp -ffast-math -LSTATIC
 
LDFLAGS := $(LDFLAGS) -O3 -fopenmp -pthread -lpthread -LSTATIC

Typed make, sent the resulting Darwin/muscle to a machine without g++-11 installed and:

% ./muscle -version
muscle 5.1.osx64 []
Built May 20 2022 10:33:54

% 

I hope that helps, -Gabo

gaboentropy avatar May 20 '22 14:05 gaboentropy

@rcedgar Firstly, thanks for MUSCLE, I've been a big fan of v3, and only discovered today that you've put out v5. I've read your comments on https://github.com/rcedgar/muscle/wiki/Contributing-to-MUSCLE --- I'm happy to help with packaging for macOS via brew (the appropriate place, imo, would be the brewsci/homebrew-bio repo).

I've successfully cooked up a Homebrew recipe to build muscle from source (at least, it works on my M1 Mac with Monterey 12.6). This uses clang, and links against libomp (this works either dynamically or statically). My CPU usage appropriately peaks to >800% in a small alignment task, so the OpenMP code is working.

Tomorrow night after work, I'll be putting in a draft PR here to start discussing some (minor) changes that I'd like to push back into this repo that make this work, and a draft PR into brewsci/bio shortly afterwards.

blake-riley avatar Oct 05 '22 07:10 blake-riley

My understanding is that the main goal of your Makefile in this repo is to create a statically-linked executable[^1] specifically for the tagged GitHub releases? i.e. so It Just Works™ when people download the build artifact?

[^1]: or as static as possible, in the case of macOS

blake-riley avatar Oct 05 '22 07:10 blake-riley

Yes, exactly. Though with Mac this may not be a good idea, MacOS seems to be more difficult about portability and I haven't tried to systematically understand this so there may be better ways to do the build.

rcedgar avatar Oct 05 '22 13:10 rcedgar

It's a matter of using a static library, instead of /usr/local/opt/gcc/lib/gcc/11/libgomp.1.dylib to use /usr/local/opt/gcc/lib/gcc/11/libgomp.a A -static option should do the trick (perhaps -static-libstdc++). I hope.

After trying I still had trouble, but this worked:

cd src
mkdir STATIC
cd STATIC
ln -s /usr/local/opt/gcc/lib/gcc/11/*.a .
cd ..

I added -LSTATIC to two lines in the Makefile, and changed g++ to g++-11:

ifeq ($(OS),Darwin)
        CXX := g++-11
endif
 
CXXFLAGS := $(CXXFLAGS) -O3 -fopenmp -ffast-math -LSTATIC
 
LDFLAGS := $(LDFLAGS) -O3 -fopenmp -pthread -lpthread -LSTATIC

Typed make, sent the resulting Darwin/muscle to a machine without g++-11 installed and:

% ./muscle -version
muscle 5.1.osx64 []
Built May 20 2022 10:33:54

% 

I hope that helps, -Gabo

This got the installer at least started for me. Paths are different (I installed gcc@11 with brew), but created the link and modified the the Makefile. However, I then get the error:

ld: unsupported tapi file type '!tapi-tbd' in YAML file '/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/usr/lib/libSystem.tbd' for architecture x86_64 I'm on macOS 12.6.2. Seems like maybe an issue with CLT? I don't know, I'm giving up for now.

Any luck getting that brew recipe running @blake-riley?

shbrainard avatar Jan 23 '23 15:01 shbrainard

Re-opening the issue because installing gcc-11 does not seem like a good solution. After poking around on google, it seems that there is no simple solution to creating a MacOS binary that runs on different releases of the O/S without requiring gcc installed. Under Linux, static linking has worked in muscle v3 well despite warnings against this method, but gcc on MacOS does not support this option. Suggestions solicitied!

Agreed, installing gcc11 doesn't seem like the most elegant solution. Has anyone figured out a proper way to statically link the library? Any current workarounds aside from installing gcc11?

Peter-Two-Point-O avatar Jan 25 '23 20:01 Peter-Two-Point-O

Cheers for the ping @shbrainard . I've just put in the PR (#47) for the updated Makefile & GitHub runner.

Once that's merged, I'll put in a PR for an update to the Homebrew recipe. Homebrew will undoubtedly prefer a dynamically linked recipe, and I can simply add libomp to the package requirements (once the above PR is through).


I gave up on gcc@11 compilers for macOS:

  • -static always crashes (missing librt.so), and Apple emphatically states "this would work, but here be dragons"
  • -static-libstdc++ gives a cryptic error [^1] and it's still linked against libstdc++.dylib (!!!) which isn't guaranteed to be on the user's machine

I figure that the proper way for macOS is to use the clang compilers, and the corresponding (i.e from LLVM) openmp implementation, libomp. The GitHub Runner image provides Homebrew, so it's pretty easy to install libomp, and reference its static library for linking.

This gives a binary that is dynamically linked against only

  • /usr/lib/libSystem.B.dylib
  • /usr/lib/libc++.1.dylib both of which are guaranteed (I think?) to be distributed with macOS.

[^1]: > ld: warning: direct access in function '__ZnamRKSt9nothrow_t.cold' from file '/usr/local/opt/gcc@11/lib/gcc/11/libstdc++.a(new_opvnt.o)' to global weak symbol '__ZnamRKSt9nothrow_t' from file '/usr/local/opt/gcc@11/lib/gcc/11/libstdc++.a(new_opvnt.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.

blake-riley avatar Jan 27 '23 05:01 blake-riley

Cheers for the ping @shbrainard . I've just put in the PR (#47) for the updated Makefile & GitHub runner.

Once that's merged, I'll put in a PR for an update to the Homebrew recipe. Homebrew will undoubtedly prefer a dynamically linked recipe, and I can simply add libomp to the package requirements (once the above PR is through).

I gave up on gcc@11 compilers for macOS:

  • -static always crashes (missing librt.so), and Apple emphatically states "this would work, but here be dragons"
  • -static-libstdc++ gives a cryptic error 1 and it's still linked against libstdc++.dylib (!!!) which isn't guaranteed to be on the user's machine

I figure that the proper way for macOS is to use the clang compilers, and the corresponding (i.e from LLVM) openmp implementation, libomp. The GitHub Runner image provides Homebrew, so it's pretty easy to install libomp, and reference its static library for linking.

This gives a binary that is dynamically linked against only

  • /usr/lib/libSystem.B.dylib
  • /usr/lib/libc++.1.dylib both of which are guaranteed (I think?) to be distributed with macOS.

Footnotes

  1. ld: warning: direct access in function '__ZnamRKSt9nothrow_t.cold' from file '/usr/local/opt/gcc@11/lib/gcc/11/libstdc++.a(new_opvnt.o)' to global weak symbol '__ZnamRKSt9nothrow_t' from file '/usr/local/opt/gcc@11/lib/gcc/11/libstdc++.a(new_opvnt.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.

Hey, awesome, thanks! I just ran "make" using the dev branch of your fork, and it got farther in the compilation than ever before. It does still throw an error though, which I pasted on the PR page.

shbrainard avatar Jan 29 '23 18:01 shbrainard

Building on @shbrainard's method:

Because homebrew installs gc++11 in a different location to avoid conflicts with clang, the make file needs to point at the homebrew directory.

Running these commands inside the src directory worked to install muscle on Apple M2 Max Ventura 13.4.1

brew install gcc@11
ln -s /opt/homebrew/bin/gcc-11 /opt/homebrew/bin/gcc
make

RareSeas-Asimov avatar Aug 08 '23 19:08 RareSeas-Asimov

Ok here is a way that I found that solves this issue on Mac silicon chip. Not ideal obviously but hey if it works right?

Install homebrew /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Install gcc@11 brew install gcc@11

In finder (or in terminal if you are more computer literate or have more patience than me)
Find /opt/homebrew/opt/gcc/lib/gcc
Open a separate tab in finder.
In this separate tab, find /opt/homebrew/opt/gcc@11/lib/gcc
Duplicate the file called 11 in this separate tab and move that to /opt/homebrew/opt/gcc/lib/gcc

Run muscle5

Hope this helps someone!

kiararey avatar Sep 29 '23 04:09 kiararey

I didn't need to do anything beyond brew install gcc@11 and then run make in the src/ folder. Hopefully it was this easy for others! Perhaps the docs can be updated if this works for more than just me (from here https://github.com/rcedgar/muscle/archive/refs/tags/5.1.0.tar.gz).

tfalkarkea avatar Jun 27 '24 18:06 tfalkarkea