EdgeApp / airbitz-core

Bitcoin wallet C/C++ API for building cross-platform applications that require user authentication, encryption, backup, and meta-data management. This library alone implements the full functionality of the Airbitz Edge Security platform and bitcoin wallet minus the graphical interface.
https://airbitz.co
Other
81 stars 43 forks source link

Cannot Build under MacOS 10.14 (Mojave) #30

Open wolfmcnally opened 5 years ago

wolfmcnally commented 5 years ago

I am attempting to build airbitz-core under MacOS 10.14 (Mojave) and am experiencing compile errors. Actually, I'd like to experiment with a minimum build of libbitcoin for iOS and your project appears to provide a straightforward infrastructure for building that. Except, I'm running into several issues. I am using Xcode 10.0 with the command line tools installed, and have installed the other build requirements via brew, per your instructions.

First I try to build airbitz-core per the README:

$ make abc.ios-universal
Running zlib.write-tasks
Running zeromq.write-tasks
Running protobuf.write-tasks
Running openssl.write-tasks
Running ndk.write-tasks
Running libsodium.write-tasks
Running libsecp256k1.write-tasks
Running libqrencode.write-tasks
Running libgit2.write-tasks
Running libcsv.write-tasks
Running libbitcoin.write-tasks
Running jansson.write-tasks
Running curl.write-tasks
Running boost.write-tasks
Running abc.write-tasks
Running abc.download
Running curl.download
Running openssl.download
Running zlib.download
Running zlib.build-ios-armv7
Running openssl.build-ios-armv7
Running curl.build-ios-armv7
Task failed (see build/curl/build-ios-armv7.log for full logs):
================================
  CC       libcurl_la-sendf.lo
  CC       libcurl_la-ftp.lo
  CC       libcurl_la-url.lo
url.c:55:2: error: "We can't compile without socket() support!"
#error "We can't compile without socket() support!"
 ^
1 error generated.
make[3]: *** [libcurl_la-url.lo] Error 1
make[2]: *** [all] Error 2
make[1]: *** [all-recursive] Error 1
================================
make: *** [build/curl/build-ios-armv7.done] Error 2 

So it looks like zlib and openssl compiled fine, but we ran into a problem with libcurl. Looking at the more complete configuration information in build-ios-armv7.log:

configure: Configured to build curl/libcurl:

  curl version:     7.50.3
  Host setup:       arm-apple-darwin10
  Install prefix:   /Users/ironwolf/DevProjects/airbitz-core/deps/build/prefix/ios/armv7
  Compiler:         clang
  SSL support:      enabled (OpenSSL)
  SSH support:      no      (--with-libssh2)
  zlib support:     enabled
  GSS-API support:  no      (--with-gssapi)
  TLS-SRP support:  enabled
  resolver:         default (--enable-ares / --enable-threaded-resolver)
  IPv6 support:     enabled
  Unix sockets support: enabled
  IDN support:      no      (--with-{libidn,winidn})
  Build libcurl:    Shared=no, Static=yes
  Built-in manual:  enabled
  --libcurl option: enabled (--disable-libcurl-option)
  Verbose errors:   enabled (--disable-verbose)
  SSPI support:     no      (--enable-sspi)
  ca cert bundle:   no
  ca cert path:     no
  ca fallback:      no
  LDAP support:     no      (--enable-ldap / --with-ldap-lib / --with-lber-lib)
  LDAPS support:    no      (--enable-ldaps)
  RTSP support:     enabled
  RTMP support:     no      (--with-librtmp)
  metalink support: no      (--with-libmetalink)
  PSL support:      no      (libpsl not found)
  HTTP2 support:    disabled (--with-nghttp2)
  Protocols:        DICT FILE FTP FTPS GOPHER HTTP HTTPS IMAP IMAPS POP3 POP3S RTSP SMB SMBS SMTP SMTPS TELNET TFTP

Making all in lib
make  all-am
  CC       libcurl_la-file.lo
  CC       libcurl_la-timeval.lo
  CC       libcurl_la-base64.lo
  CC       libcurl_la-hostip.lo
  CC       libcurl_la-progress.lo
  CC       libcurl_la-formdata.lo
  CC       libcurl_la-cookie.lo
  CC       libcurl_la-http.lo
  CC       libcurl_la-sendf.lo
  CC       libcurl_la-ftp.lo
  CC       libcurl_la-url.lo
url.c:55:2: error: "We can't compile without socket() support!"
#error "We can't compile without socket() support!"
 ^
1 error generated.
make[3]: *** [libcurl_la-url.lo] Error 1
make[2]: *** [all] Error 2
make[1]: *** [all-recursive] Error 1

Well, perhaps I don't need libcurl right now, because as I said I just want a basic build of libbitcoin to experiment with:

$ make libbitcoin.ios-universal
Running libbitcoin.download
Running boost.download
Running boost.build-ios-armv7
Task failed (see build/boost/build-ios-armv7.log for full logs):
================================
Unpacking download/boost_1_62_0.tar.bz2 to build/boost/ios-armv7...
Patching boost...
patching file boost/config/user.hpp
Bootstrapping boost...
Building Boost.Build engine with toolset darwin... 
Failed to build Boost.Build build engine
Consult 'bootstrap.log' for more details
================================
make: *** [build/boost/build-ios-armv7.done] Error 1

So boost failed to bootstrap. Looking at: ./build/boost/ios-armv7/boost_1_62_0/bootstrap.log:

###
### Using 'darwin' toolset.
###
rm -rf bootstrap
mkdir bootstrap
cc -o bootstrap/jam0 command.c compile.c constants.c debug.c execcmd.c frames.c function.c glob.c hash.c hdrmacro.c headers.c jam.c jambase.c jamgram.c lists.c make.c make1.c object.c option.c output.c parse.c pathsys.c regexp.c rules.c scan.c search.c subst.c timestamp.c variable.c modules.c strings.c filesys.c builtins.c class.c cwd.c native.c md5.c w32_getreg.c modules/set.c modules/path.c modules/regex.c modules/property-set.c modules/sequence.c modules/order.c execunix.c fileunix.c pathunix.c
In file included from command.c:17:
./jam.h:333:10: fatal error: 'sys/types.h' file not found
#include <sys/types.h>
         ^~~~~~~~~~~~~
1 error generated.
In file included from compile.c:23:
./jam.h:333:10: fatal error: 'sys/types.h' file not found
#include <sys/types.h>
         ^~~~~~~~~~~~~
1 error generated.
In file included from debug.c:8:
./jam.h:333:10: fatal error: 'sys/types.h' file not found
#include <sys/types.h>
         ^~~~~~~~~~~~~
1 error generated.
...

So the bootstrap script can't find <sys/types.h>.

I can build libsecp256k1:

$ make libsecp256k1.ios-universal
Running libsecp256k1.download
Running libsecp256k1.build-ios-armv7
Running libsecp256k1.build-ios-armv7s
Running libsecp256k1.build-ios-arm64
Running libsecp256k1.build-ios-i386
Running libsecp256k1.build-ios-x86_64
Running libsecp256k1.ios-universal
$ lipo -info build/libsecp256k1/ios-universal/lib/libsecp256k1.a
Architectures in the fat file: build/libsecp256k1/ios-universal/lib/libsecp256k1.a are: armv7 armv7s i386 x86_64 arm64 

So clearly the build system is mostly working— it's just certain dependencies that are broken.

A fix, workaround, or pointer to where I might start fixing it myself would be appreciated.

swansontec commented 5 years ago

We sometimes encounter problems like these when Xcode isn't correctly set up. Try running xcode-select --install to ensure that the command-line tools are properly configured. When basic system functions like socket are missing, it's usually a sign that the build tools aren't getting the right SDK for some reason. Look at the "deps/classes/ios" file, which is a shell script that sets up the environment variables for iOS.

wolfmcnally commented 5 years ago

Thanks for your response. I have run xcode-select --install so everything is fine there. I'm not sure what might be wrong with the classes/ios file, although I have looked at it.

For now my workaround is to focus on building libbitcoin by itself, which I now have been able to do by separating the Boost bootstrap phase from the build phase. I'll have a PR shortly that fixes that.

swansontec commented 5 years ago

I see, so you are just bypassing the rest of the Airbitz dependencies, and focusing on the libbitcoin immediate requirements. Of those, only boost is genuinely broken. That's promising! The boost build system is pretty awful, so having it break isn't too surprising.