Closed sergeymild closed 2 years ago
See the project ssl directory, darwin system (including ios) uses built-in appletls (ie Security). If you want to use SSL/TLS function on android, you may need ./configure --with-openssl
first ./configure
,and you can find #define HAVE_GETTID 0
in hconfig.h
on mac platform.
after make libhv i receive this:
mkdir -p 2>/dev/null lib
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f Makefile.in TARGET=libhv TARGET_TYPE="SHARED|STATIC" SRCDIRS=". base ssl event util cpputil evpp http http/server http/client"
Apple clang version 13.0.0 (clang-1300.0.29.30)
OS = Darwin
ARCH = x86_64
MAKE = /Applications/Xcode.app/Contents/Developer/usr/bin/make
CC = cc
CXX = c++
CFLAGS = -O2 -fPIC -std=c99
CXXFLAGS = -O2 -fPIC -std=c++11
CPPFLAGS = -DNDEBUG -Iinclude -I3rd -I3rd/include -I. -Ibase -Issl -Ievent -Iutil -Icpputil -Ievpp -Ihttp -Ihttp/server -Ihttp/client -DWITH_OPENSSL
LDFLAGS = -lssl -lcrypto -Llib -L3rd/lib -L3rd/lib/x86_64-apple-darwin21.3.0 -lstdc++ -lpthread -lm -ldl -framework CoreFoundation -framework Security
TARGET = libhv
TARGET_TYPE = SHARED|STATIC
TARGET_PLATFORM = x86_64-apple-darwin21.3.0
BUILD_TYPE = RELEASE
SRCS=base/hbase.c base/herr.c base/hlog.c base/hmain.c base/hsocket.c base/htime.c base/hversion.c base/rbtree.c ssl/appletls.c ssl/gnutls.c ssl/hssl.c ssl/mbedtls.c ssl/nossl.c ssl/openssl.c ssl/wintls.c event/epoll.c event/evport.c event/hevent.c event/hloop.c event/iocp.c event/kqueue.c event/nio.c event/nlog.c event/noevent.c event/overlapio.c event/poll.c event/rudp.c event/select.c event/unpack.c util/base64.c util/md5.c util/sha1.c cpputil/RAII.cpp cpputil/ThreadLocalStorage.cpp cpputil/hasync.cpp cpputil/hdir.cpp cpputil/hpath.cpp cpputil/hstring.cpp cpputil/hurl.cpp cpputil/ifconfig.cpp cpputil/iniparser.cpp http/http_parser.c http/httpdef.c http/multipart_parser.c http/websocket_parser.c http/wsdef.c http/Http1Parser.cpp http/Http2Parser.cpp http/HttpMessage.cpp http/HttpParser.cpp http/WebSocketParser.cpp http/http_content.cpp http/server/FileCache.cpp http/server/HttpHandler.cpp http/server/HttpServer.cpp http/server/HttpService.cpp http/server/http_page.cpp http/client/AsyncHttpClient.cpp http/client/WebSocketClient.cpp http/client/http_client.cpp
OBJS=base/hbase.o base/herr.o base/hlog.o base/hmain.o base/hsocket.o base/htime.o base/hversion.o base/rbtree.o ssl/appletls.o ssl/gnutls.o ssl/hssl.o ssl/mbedtls.o ssl/nossl.o ssl/openssl.o ssl/wintls.o event/epoll.o event/evport.o event/hevent.o event/hloop.o event/iocp.o event/kqueue.o event/nio.o event/nlog.o event/noevent.o event/overlapio.o event/poll.o event/rudp.o event/select.o event/unpack.o util/base64.o util/md5.o util/sha1.o cpputil/RAII.o cpputil/ThreadLocalStorage.o cpputil/hasync.o cpputil/hdir.o cpputil/hpath.o cpputil/hstring.o cpputil/hurl.o cpputil/ifconfig.o cpputil/iniparser.o http/http_parser.o http/httpdef.o http/multipart_parser.o http/websocket_parser.o http/wsdef.o http/Http1Parser.o http/Http2Parser.o http/HttpMessage.o http/HttpParser.o http/WebSocketParser.o http/http_content.o http/server/FileCache.o http/server/HttpHandler.o http/server/HttpServer.o http/server/HttpService.o http/server/http_page.o http/client/AsyncHttpClient.o http/client/WebSocketClient.o http/client/http_client.o
mkdir -p 2>/dev/null bin lib
cc -O2 -fPIC -std=c99 -DNDEBUG -Iinclude -I3rd -I3rd/include -I. -Ibase -Issl -Ievent -Iutil -Icpputil -Ievpp -Ihttp -Ihttp/server -Ihttp/client -DWITH_OPENSSL -c -o base/hmain.o base/hmain.c
cc -O2 -fPIC -std=c99 -DNDEBUG -Iinclude -I3rd -I3rd/include -I. -Ibase -Issl -Ievent -Iutil -Icpputil -Ievpp -Ihttp -Ihttp/server -Ihttp/client -DWITH_OPENSSL -c -o base/hsocket.o base/hsocket.c
cc -O2 -fPIC -std=c99 -DNDEBUG -Iinclude -I3rd -I3rd/include -I. -Ibase -Issl -Ievent -Iutil -Icpputil -Ievpp -Ihttp -Ihttp/server -Ihttp/client -DWITH_OPENSSL -c -o base/htime.o base/htime.c
cc -O2 -fPIC -std=c99 -DNDEBUG -Iinclude -I3rd -I3rd/include -I. -Ibase -Issl -Ievent -Iutil -Icpputil -Ievpp -Ihttp -Ihttp/server -Ihttp/client -DWITH_OPENSSL -c -o base/hversion.o base/hversion.c
cc -O2 -fPIC -std=c99 -DNDEBUG -Iinclude -I3rd -I3rd/include -I. -Ibase -Issl -Ievent -Iutil -Icpputil -Ievpp -Ihttp -Ihttp/server -Ihttp/client -DWITH_OPENSSL -c -o base/rbtree.o base/rbtree.c
cc -O2 -fPIC -std=c99 -DNDEBUG -Iinclude -I3rd -I3rd/include -I. -Ibase -Issl -Ievent -Iutil -Icpputil -Ievpp -Ihttp -Ihttp/server -Ihttp/client -DWITH_OPENSSL -c -o ssl/appletls.o ssl/appletls.c
cc -O2 -fPIC -std=c99 -DNDEBUG -Iinclude -I3rd -I3rd/include -I. -Ibase -Issl -Ievent -Iutil -Icpputil -Ievpp -Ihttp -Ihttp/server -Ihttp/client -DWITH_OPENSSL -c -o ssl/gnutls.o ssl/gnutls.c
cc -O2 -fPIC -std=c99 -DNDEBUG -Iinclude -I3rd -I3rd/include -I. -Ibase -Issl -Ievent -Iutil -Icpputil -Ievpp -Ihttp -Ihttp/server -Ihttp/client -DWITH_OPENSSL -c -o ssl/hssl.o ssl/hssl.c
cc -O2 -fPIC -std=c99 -DNDEBUG -Iinclude -I3rd -I3rd/include -I. -Ibase -Issl -Ievent -Iutil -Icpputil -Ievpp -Ihttp -Ihttp/server -Ihttp/client -DWITH_OPENSSL -c -o ssl/mbedtls.o ssl/mbedtls.c
cc -O2 -fPIC -std=c99 -DNDEBUG -Iinclude -I3rd -I3rd/include -I. -Ibase -Issl -Ievent -Iutil -Icpputil -Ievpp -Ihttp -Ihttp/server -Ihttp/client -DWITH_OPENSSL -c -o ssl/nossl.o ssl/nossl.c
cc -O2 -fPIC -std=c99 -DNDEBUG -Iinclude -I3rd -I3rd/include -I. -Ibase -Issl -Ievent -Iutil -Icpputil -Ievpp -Ihttp -Ihttp/server -Ihttp/client -DWITH_OPENSSL -c -o ssl/openssl.o ssl/openssl.c
ssl/openssl.c:5:10: fatal error: 'openssl/ssl.h' file not found
#include "openssl/ssl.h"
^~~~~~~~~~~~~~~
1 error generated.
make[1]: *** [ssl/openssl.o] Error 1
make: *** [libhv] Error 2
as i understand i need compile openssl first and put it somewhere?
Yes, you should make sure openssl is installed in a searchable path such as /usr/include
、/usr/local/include
or libhv/3rd/include
Sorry for my stupid) but now i receive this one:
/opt/ndk/x86_64/bin/../lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/bin/ld: error: cannot find -lssl
/opt/ndk/x86_64/bin/../lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/bin/ld: error: cannot find -lcrypto
and even if i fix it somehow i receive another errors:
/opt/ndk/x86_64/bin/../lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/bin/ld: error: ssl: no archive symbol table (run ranlib)
/opt/ndk/x86_64/bin/../lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/bin/ld: error: crypto: no archive symbol table (run ranlib)
I got libhv working in my Android project. Firstly I compiled official openssl sources for Android as in: https://github.com/openssl/openssl/blob/master/NOTES-ANDROID.md Then I copied openssl libs to self-created folder "android-openssl/openssl" only for two main architectures arm, arm64. After that made the following steps (I am not sure if all these steps needed, but at least it worked finally): LIBHV building for Android:
if PATH is not working correctly in MAKE then add it to Makefile manually on 4-th line: export PATH := /opt/ndk/arm64/bin:/opt/ndk/arm/bin:/home/kanat/android-openssl/openssl:/home/kanat/android-openssl/openssl/arm64-v8a/lib:/home/kanat/android-openssl/openssl/arm64-v8a/include:/home/kanat/android-openssl/openssl/armeabi-v7a/lib:/home/kanat/android-openssl/openssl/arm64-v8a/bin:$(PATH)
In Makefile.in do this as in git diff: --- a/Makefile.in +++ b/Makefile.in @@ -112,8 +112,8 @@ DISTDIR = dist DOCDIR = docs
SRCDIRS += $(shell find $(SRCDIR) -type d) -override INCDIRS += $(INCDIR) $(DEPDIR) $(DEPDIR)/include -override LIBDIRS += $(LIBDIR) $(DEPDIR)/lib $(DEPDIR)/lib/$(TARGET_PLATFORM) +override INCDIRS += $(INCDIR) $(DEPDIR) $(DEPDIR)/include /home/kanat/android-openssl/openssl/armeabi-v7a/include +override LIBDIRS += $(LIBDIR) $(DEPDIR)/lib $(DEPDIR)/lib/$(TARGET_PLATFORM) /home/kanat/android-openssl/openssl/armeabi-v7a/lib
Build libhv: export NDK_ROOT=/home/kanat/android-ndk-r21e sudo $NDK_ROOT/build/tools/make-standalone-toolchain.sh --arch=arm --platform=android-16 --install-dir=/opt/ndk/arm sudo $NDK_ROOT/build/tools/make-standalone-toolchain.sh --arch=arm64 --platform=android-21 --install-dir=/opt/ndk/arm64 export PATH=/opt/ndk/arm/bin:/opt/ndk/arm64/bin:$PATH
export CROSS_COMPILE=arm-linux-androideabi- ./configure --with-openssl make clean make libhv
export CROSS_COMPILE=aarch64-linux-android- ./configure --with-openssl make clean make libhv
Maybe it can help you somehow.
Hi, there is a test websockets site
socketsbay.com
where can test websocket client, on ios it works well, but on android i always receive this errorW/JNI: connfd=146 connect error: Unknown error 1041:1041
also i cant do any https requests, again on ios everything works fine.