Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arm64 problem while configure #28

Closed
arik-so opened this issue Apr 17, 2014 · 14 comments
Closed

Arm64 problem while configure #28

arik-so opened this issue Apr 17, 2014 · 14 comments

Comments

@arik-so
Copy link

arik-so commented Apr 17, 2014

I have the latest Xcode version, and when executing the build script, all architectures work fine, except for arm64. When I get to arm64, the shell prints:
Problem while make - Please check […]/OpenSSL-for-iPhone-master/bin/iPhoneOS7.1-arm64.sdk/build-openssl-1.0.1g.log

When looking at the log, these are the last lines:
/opt/local/bin/ranlib: /opt/local/bin/ranlib: cannot execute binary file
ar: internal ranlib command failed
make[1]: *** [../libcrypto.a] Error 1
make: *** [build_crypto] Error 1

I googled the issue, and found this page: http://lists.cs.uiuc.edu/pipermail/llvmbugs/2014-March/033328.html, which suggested I change the ranlib path. So I changed my /opt/local/bin/ranlib alias to the recommended path suggested on the page, '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib', add then all architectures stopped working. I filtered the generation to arm64, but it still didn't work for that one, and the error remained the same. So I reversed to the original ranlib alias, and the other architectures except for arm64 resumed working.

Still, I really need it to compile for arm64. Could you suggest any resolutions to the issue?

@x2on
Copy link
Owner

x2on commented Apr 17, 2014

I have tested it with Xcode 5.1.1 and it works fine on different Macs, so i think something is broken on your system!

Downloading openssl-1.0.1g.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 4403k  100 4403k    0     0  3240k      0  0:00:01  0:00:01 --:--:-- 3242k
Building openssl-1.0.1g for iPhoneSimulator 7.1 i386
Please stand by...
Building openssl-1.0.1g for iPhoneSimulator 7.1 x86_64
Please stand by...
Building openssl-1.0.1g for iPhoneOS 7.1 armv7
Please stand by...
Building openssl-1.0.1g for iPhoneOS 7.1 armv7s
Please stand by...
Building openssl-1.0.1g for iPhoneOS 7.1 arm64
Please stand by...
Build library...
Building done.
Cleaning up...
Done.
$> file lib/libssl.a 
lib/libssl.a: Mach-O universal binary with 5 architectures
lib/libssl.a (for architecture i386):   current ar archive random library
lib/libssl.a (for architecture x86_64): current ar archive random library
lib/libssl.a (for architecture armv7):  current ar archive random library
lib/libssl.a (for architecture armv7s): current ar archive random library
lib/libssl.a (for architecture cputype (16777228) cpusubtype (0)):  current ar archive random library

@x2on x2on closed this as completed Apr 17, 2014
@x2on
Copy link
Owner

x2on commented Apr 17, 2014

You could also have a look at the travis-ci build which works fine:

https://travis-ci.org/x2on/OpenSSL-for-iPhone#L8373

$> xcrun -sdk iphoneos lipo -info ./lib/*.a
Architectures in the fat file: ./lib/libcrypto.a are: i386 x86_64 armv7 armv7s arm64 
Architectures in the fat file: ./lib/libssl.a are: i386 x86_64 armv7 armv7s arm64 

@isa56k
Copy link

isa56k commented Apr 25, 2014

Hi,

I'm also hitting exactly the same issue.

@arik-so - Did you manage to resolve this? If so any advice on what you did to fix it?

TIA.

@rsodre
Copy link

rsodre commented Apr 26, 2014

It happened to me when I upgraded to Xcode 5.1.1
I fixed by downloading again the Command Line Tools (Preferences, Downloads)

@isa56k
Copy link

isa56k commented Apr 26, 2014

Hi @rsodre ,

When I go to Preferences > Downloads I don't see command line tools?

If I try to do xcode-select --install I get the error "Can't install the software because it is not currently available from the software update server". From reading around I think this a bit of a spurious error and is generated when command line tools already exist.

I have downloaded separately and installed from https://developer.apple.com/downloads and installed but still I get the same ranlib error when trying to build for arm64.

Two questions, where does xcode-select -p point to on your machine and is /opt/local/bin/ranlib a sym link to libtool ?

mymac:OpenSSL-for-iPhone isa56k$ ls -lamo /opt/local/bin/ranlib
lrwxr-xr-x 1 root 7 8 Feb 07:06 /opt/local/bin/ranlib -> libtool

TIA

@x2on
Copy link
Owner

x2on commented Apr 26, 2014

On my machine /opt/local/bin/ranlib doesn't exists and the build of OpenSSL works fine.

$ ls -lamo /opt/local/bin/ranlib
ls: /opt/local/bin/ranlib: No such file or directory

@isa56k
Copy link

isa56k commented Apr 26, 2014

@x2on Oh.. hmm.. what does $ which ranlib give you?

@isa56k
Copy link

isa56k commented Apr 26, 2014

At last it has built... :)

I think it must be to do with the sym link to libtool.

I just removed it and then did a which on ranlib, this pointed to /usr/bin/ranlib. I tried to build again and it failed with the error below:

ar r ../libcrypto.a cryptlib.o mem.o mem_dbg.o cversion.o ex_data.o cpt_err.o ebcdic.o uid.o o_time.o o_str.o o_dir.o o_fips.o o_init.o fips_ers.o mem_clr.o
ar: creating archive ../libcrypto.a
ar: can't find or exec: /opt/local/bin/ranlib (No such file or directory)
ar: internal ranlib command failed

I then cp /usr/bin/ranlib to /opt/local/bin/ranlib and re ran the build script, this time it ahs all built successfully.

Why I had a sym link to libtool from ranlib in the first place don't know, even the freshly downloaded command line tools seemed to have this.

I expect it is something messed up in my config somewhere, exactly where I'm not really sure or why. Anyways, it's compiled now!

Thanks for comments... It's got me going in right direction. :)

@x2on
Copy link
Owner

x2on commented Apr 27, 2014

$ which ranlib
/usr/bin/ranlib

@buddydvd
Copy link

I had the same issue and, after some investigation, I discovered the root cause was due to me having installed MacPorts. Apparently, MacPorts installs a version of ranlib/libtool to /opt/local/bin which conflicts with the build process. I tried (but failed) to workaround this issue by explicitly declaring the path to ranlib by inserting this line into build-libssl.sh:

export RANLIB="`${BUILD_TOOLS}/usr/bin/xcrun --find ranlib`"

since OpenSSL's Configure script carries the RANLIB value to the generated Makefile. Unfortunately, the generated Makefile still chooses the default (implicitly determined) path instead of the explicitly declared path.

So, in summary, the solution is to uninstall MacPorts.

x2on added a commit that referenced this issue May 1, 2014
@x2on
Copy link
Owner

x2on commented May 1, 2014

Thanks for the investigation - i added a hint to the Readme about MacPorts.

@kewinwang
Copy link

I meet the problem and even I have not install Macport (I use brew mostly) ,any help?

i try to use https://gist.githubusercontent.com/foozmeat/5154962/raw/23029f08d3475a75269e2e05d7388355f745d641/openssl-build.sh
build successfully ,but meet the follow problem :

ld: library not found for -lcrypto
clang: error: linker command failed with exit code 1 (use -v to see invocation)

@vixentael
Copy link

Hello from 2015! :)

Thank you @isa56k for your tips. I tried lots of suggestions, but yours worked.

I have the same issue on Yosemite 10.10.5 with Xcode 7.1 and installed Command Line Tools. Cocoapods 0.39.0. No MacPorts.

I found that ranlib was linked to libtool.

~ ls -lamo /opt/local/bin/ranlib          
lrwxr-xr-x  1 root  7 Jan 30  2014 /opt/local/bin/ranlib -> libtool

I removed link and copied ranlib from /usr/bin/ranlib

~ sudo rm /opt/local/bin/ranlib
~ sudo cp /usr/bin/ranlib /opt/local/bin/ranlib
~ ls -lamo /opt/local/bin/ranlib          
-rwxr-xr-x+ 1 root  14160 Oct 27 16:21 /opt/local/bin/ranlib
~ which ranlib
/opt/local/bin/ranlib

Just in case, I read that there could be similar issues with ar. My ar was okay.

~ which ar    
/opt/local/bin/ar
~ ls -lamo /opt/local/bin/ar    
-r-xr-xr-x+ 1 root  32176 Jul  5  2013 /opt/local/bin/ar

@raybellis
Copy link

I found it was sufficient just to temporarily remove /opt/local/bin from my path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants