1

I've long been a user of RcppArmadillo, but have been unable to compile any programs via sourceCpp since upgrading my OS to Monterey Version 12.3.

Getting the following error:

ld: malformed universal file: slice content is not mach-o or a static library file '/usr/local/lib/libgfortran.dylib'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [sourceCpp_2.so] Error 1

It seems like this has something to do with static vs dynamic linking judging by the post here but I really have no idea.

  • See if [this resource helps](https://thecoatlessprofessor.com/programming/cpp/r-compiler-tools-for-rcpp-on-macos/). It's a problem within your fortran libraries. So this should work. – Kat Mar 18 '22 at 21:05
  • This was one of the many solutions that I tried. It didn't help. – Alexander McLain Mar 22 '22 at 20:23
  • This error happens too when you try to build grub in osdev purposes... – Patryk Szczepański Aug 17 '22 at 19:45
  • And changing the `clang` to built-in `gcc` does not fix it. I reported it to GNU team, will see if they fix the issue, or I'm forced to use Linux docker/VM to build my old own osdev project. – Patryk Szczepański Aug 17 '22 at 20:10

3 Answers3

2

I got the same ld error when I upgraded to Xcode 13.3. I've reverted to 13.2 and my projects build with no errors. I'll stay with 13.2 until I see more information coming out on what's causing this problem.

JHRM
  • 21
  • 1
  • This worked for me. Very disappointing that this is needed. On my other computer, I did actually find a solution without going back to Xcode 13.2. Unfortunately, it's not anything that I can reproduce as I tried a bunch of different stuff. – Alexander McLain Mar 22 '22 at 21:03
1

Reinstall RcppArmadillo

-> install.packages("RcppArmadillo", type = "source")

If something wrong, try to modify your makeconf file:

FLIBS = -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin21/11.2.0 #-L/usr/local/gfortran/lib -lgfortran -lquadmath -lm

Cheng
  • 11
  • 1
0

This is from the XCode 13.3 release notes. I guess the issue is related to this change.

The new chained fixups format is the default linking method when targeting macOS 11 or later, iOS 13.4 or later, watchOS 7.0 or later, and tvOS 14.0 or later. This new format results in smaller LINKEDIT segments in binaries. When targeting earlier operating system releases, the linker continues to generate the traditional opcode format in LINKEDIT for fixups, rebases, and binds. (85572905)