krzyzanowskim/OpenSSL

[Question] Error - Building for iOS Simulator-x86_64 but attempting to link with file built for macOS-arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

dinbtechit opened this issue · 6 comments

I am trying to build OpenSSL on my M1 Mac. I would like to build OpenSSL for the following targets - aarch64-apple-ios ,x86_64-apple-ios and aarch64-apple-ios-sim

I followed the manual steps:

$ git clone https://github.com/krzyzanowskim/OpenSSL.git
$ cd OpenSSL
$ make

But got the below error:

ld: in '/opt/homebrew/opt/llvm/lib/libunwind.dylib', building for iOS Simulator-x86_64 but attempting to link with file built for macOS-arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Any idea how to resolve this error?

I am getting this

/usr/local/Cellar/perl/5.36.0/bin/perl "-I." -Mconfigdata "util/dofile.pl" \
	    "-oMakefile" include/crypto/bn_conf.h.in > include/crypto/bn_conf.h
/usr/local/Cellar/perl/5.36.0/bin/perl "-I." -Mconfigdata "util/dofile.pl" \
	    "-oMakefile" include/crypto/dso_conf.h.in > include/crypto/dso_conf.h
/usr/local/Cellar/perl/5.36.0/bin/perl "-I." -Mconfigdata "util/dofile.pl" \
	    "-oMakefile" include/openssl/opensslconf.h.in > include/openssl/opensslconf.h
/Applications/Xcode.app/Contents/Developer/usr/bin/make depend && /Applications/Xcode.app/Contents/Developer/usr/bin/make _all
xcrun -sdk iphonesimulator cc  -I. -Iinclude -fPIC -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.2.sdk -fno-common -fembed-bitcode -mios-version-min=7.0 -mios-simulator-version-min=7.0 -arch x86_64 -O3 -DL_ENDIAN -DOPENSSL_PIC -DOPENSSLDIR="\"/var/folders/1k/fhbyykj91_78lnf_4gh9mb6r0000gp/T/tmp.q5d40QWz/1.1.1s-iPhoneSimulator-x86_64/ssl\"" -DENGINESDIR="\"/var/folders/1k/fhbyykj91_78lnf_4gh9mb6r0000gp/T/tmp.q5d40QWz/1.1.1s-iPhoneSimulator-x86_64/lib/engines-1.1\"" -D_REENTRANT -DNDEBUG   -c -o apps/app_rand.o apps/app_rand.c
/opt/X11/bin/makedepend -f- -Y --  -I. -Iinclude -fPIC -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.2.sdk -fno-common -fembed-bitcode -mios-version-min=7.0 -mios-simulator-version-min=7.0 -arch x86_64 -O3 -DL_ENDIAN -DOPENSSL_PIC -DOPENSSLDIR="\"/var/folders/1k/fhbyykj91_78lnf_4gh9mb6r0000gp/T/tmp.q5d40QWz/1.1.1s-iPhoneSimulator-x86_64/ssl\"" -DENGINESDIR="\"/var/folders/1k/fhbyykj91_78lnf_4gh9mb6r0000gp/T/tmp.q5d40QWz/1.1.1s-iPhoneSimulator-x86_64/lib/engines-1.1\"" -D_REENTRANT -DNDEBUG  -- apps/app_rand.c 2>/dev/null \
	    > apps/app_rand.d
make[2]: *** [apps/app_rand.o] Error 1
make[1]: *** [all] Error 2

I'm sorry but all I have to say is It works on my machine It obviously has something with installed deps and paths. I don't know, and don't even try to debug it remotely

Can you please provide me precompiled binaries libcrypto and libssl multi-arch for iOS?

I'm sorry but all I have to say is It works on my machine It obviously has something with installed deps and paths. I don't know, and don't even try to debug it remotely

@krzyzanowskim - interesting.. Can you share the lib and include the directory for aarch64 ios-sim?

@krzyzanowskim - Thank you. I did not realize you managed to use the same libraries for both arm64 and x86 ios simulators. I dont know if rust would like it tho. Let me try building my rust project using these static libraries. 🙌

P.S - I was able to build after uninstalling llvm successfully brew uninstall llvm