echoprint-codegen icon indicating copy to clipboard operation
echoprint-codegen copied to clipboard

Build fails on macOS 10.13 with Xcode 9

Open fxcoudert opened this issue 8 years ago • 3 comments

Building on macOS 10.13 with Xcode 9 fails with:

libtool -dynamic -flat_namespace -install_name libcodegen.4.1.2.dylib -lSystem -compatibility_version 4.1 \
		-macosx_version_min 10.6 -current_version 4.1.2 -o libcodegen.4.1.2.dylib -undefined suppress \
	    AudioBufferInput.o AudioStreamInput.o Base64.o Codegen.o Fingerprint.o MatrixUtility.o SubbandAnalysis.o Whitening.o -framework Accelerate
ld: file not found: 
fatal error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: internal link edit command failed
make: *** [libcodegen] Error 1

when running make -C src install

fxcoudert avatar Oct 04 '17 12:10 fxcoudert

I'm having a similar issue. Reduced example:

#!/bin/sh
echo 'int main(void) { return 0; }' > test.c
clang -c test.c
SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk \
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool \
-v -dynamic -o test.dylib test.o

+ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld -arch_multiple -arch x86_64 -dylib -dynamic -all_load -force_cpusubtype_ALL -no_arch_warnings /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/dylib1.o test.o -o test.dylib 
ld: file not found: 
fatal error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: internal link edit command failed

After up to a few dozen runs, it eventually executes successfully.

It randomly (and frequently) happens with any local projects as well when building dylibs. I remember a similar issue after upgrading to Sierra, which was resolved by disabling parallel builds. Parallel builds are still disabled, and the issue came back right after upgrading to High Sierra.

Ref: Apple Radar 34944562 Ref: https://trac.macports.org/ticket/54825

vszakats avatar Oct 12 '17 00:10 vszakats

I received a reply from Apple, where this was confirmed to be a libtool (cctools) issue which will be addressed in a future Xcode release. Apple suggested to replace libtool -dynamic with $CC -dynamiclib (which is the recommended way to create dylibs) to get around the problem.

vszakats avatar Nov 11 '17 13:11 vszakats

On MacOS 11 I had to also remove -lSystem and -framework Accelerate from that libtool command line to get it to link libcodegen.4.1.2.dylib

mitchblank avatar Feb 09 '21 16:02 mitchblank