Closed Clovel closed 4 years ago
Replacing Applications/Lock/Main.c
by Applications/Main.c
, we get a whole new kind of error.
On step
clang -Wall -Werror -DHAP_ENABLE_DEVELOPMENT_ONLY_CODE=1 -ffunction-sections -fdata-sections -IHAP -IExternal/HTTP -IExternal/JSON -IExternal/Base64 -IPAL -I/include -O0 -g -DHAP_LOG_LEVEL=1 -DHAP_TESTING -IPAL/Mock -I/include -o Output/Linux-x86_64-pc-linux-gnu/Test/Tests/HAPImportTest.OpenSSL -Wl,--start-group -ldns_sd -lsqlite3 -pthread -lasound -lopus -lfaac -lm -L/lib -lcrypto Output/Linux-x86_64-pc-linux-gnu/Test/PAL/HAPPlatformSystemInit.o Output/Linux-x86_64-pc-linux-gnu/Test/Tests/HAPImportTest.o Output/Linux-x86_64-pc-linux-gnu/Test/hap.a Output/Linux-x86_64-pc-linux-gnu/Test/Mock.a Output/Linux-x86_64-pc-linux-gnu/Test/OpenSSL.a -Wl,--end-group
I get the following error :
/usr/bin/ld: cannot find -ldns_sd
/usr/bin/ld: cannot find -lsqlite3
/usr/bin/ld: cannot find -lasound
/usr/bin/ld: cannot find -lopus
/usr/bin/ld: cannot find -lfaac
/usr/bin/ld: cannot find -ldns_sd
/usr/bin/ld: cannot find -lsqlite3
/usr/bin/ld: cannot find -lasound
/usr/bin/ld: cannot find -lopus
/usr/bin/ld: cannot find -lfaac
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [Build/Makefile:146: Output/Linux-x86_64-pc-linux-gnu/Test/Tests/HAPBLEEventTest.OpenSSL] Error 1
make[1]: *** Waiting for unfinished jobs....
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [Build/Makefile:146: Output/Linux-x86_64-pc-linux-gnu/Test/Tests/HAPCryptoTest.OpenSSL] Error 1
/usr/bin/ld: cannot find -ldns_sd
/usr/bin/ld: cannot find -lsqlite3
/usr/bin/ld: cannot find -lasound
/usr/bin/ld: cannot find -lopus
/usr/bin/ld: cannot find -lfaac
/usr/bin/ld: cannot find -ldns_sd
/usr/bin/ld: cannot find -lsqlite3
/usr/bin/ld: cannot find -lasound
/usr/bin/ld: cannot find -lopus
/usr/bin/ld: cannot find -lfaac
/usr/bin/ldclang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [Build/Makefile:146: Output/Linux-x86_64-pc-linux-gnu/Test/Tests/HAPJSONUtilsTest.OpenSSL] Error 1
: cannot find -ldns_sd
/usr/bin/ld: cannot find -lsqlite3
/usr/bin/ld: cannot find -lasound
/usr/bin/ld: cannot find -lopus
/usr/bin/ld: cannot find -lfaac
/usr/bin/ld: cannot find -ldns_sd
/usr/bin/ldclang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [Build/Makefile:146: Output/Linux-x86_64-pc-linux-gnu/Test/Tests/HAPBase+IntTests.OpenSSL] Error 1
: cannot find -lsqlite3
/usr/bin/ld: cannot find -lasound
/usr/bin/ld: cannot find -lopus
/usr/bin/ld: cannot find -lfaac
/usr/bin/ld: cannot find -ldns_sd
/usr/bin/ld: cannot find -lsqlite3
/usr/bin/ld/usr/bin/ld: cannot find -ldns_sd
/usr/bin/ld: cannot find -lsqlite3
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [Build/Makefile:146: Output/Linux-x86_64-pc-linux-gnu/Test/Tests/HAPTLVTest.OpenSSL] Error 1
/usr/bin/ld: cannot find -lasound
/usr/bin/ld: cannot find -lasound
/usr/bin/ld: cannot find -lopus
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [Build/Makefile:146: Output/Linux-x86_64-pc-linux-gnu/Test/Tests/HAPIPAccessoryProtocolReadStringCharacteristicWriteRequestsTest.OpenSSL] Error 1
/usr/bin/ld: cannot find -lopus
/usr/bin/ld: cannot find -lfaac
: cannot find -lfaac
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [Build/Makefile:146: Output/Linux-x86_64-pc-linux-gnu/Test/Tests/HAPUTF8Test.OpenSSL] Error 1
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [Build/Makefile:146: Output/Linux-x86_64-pc-linux-gnu/Test/Tests/HAPImportTest.OpenSSL] Error 1
make[1]: Leaving directory '/home/XXXX/repository/HomeKitADK'
make: *** [Makefile:45: all] Error 2
There seems to be missing dependencies, that should be specified in the documentation.
Yet, I have /usr/lib/x86_64-linux-gnu/libsqlite3.so.0
. Even setting manualy the path to this library in LD_LIBRARY_PATH
results in a /usr/bin/ld: cannot find -lsqlite3
error.
It turns out clang does not like when there are version numbers on libraries.
For example : /usr/bin/ld: cannot find -lsqlite3
was fixed on my system by doing :
cd /usr/lib/x86_64-linux-gnu/
sudo ln -s libsqlite3.so.0 libsqlite3.so
cd -
make
/usr/bin/ld: cannot find -lfaac
is fixed by sudo apt install libfaac-dev
/usr/bin/ld: cannot find -lasound
is fixed by sudo apt install libasound-dev
/usr/bin/ld: cannot find -lopus
is fixed by sudo apt install libopus-dev
/usr/bin/ld: cannot find -ldns_sd
is fixed by sudo apt install libavahi-compat-libdnssd-dev
Using make TARGET=Linux
, on step
-DHAP_TESTING -IPAL/Linux -IPAL/Linux -DHAP_Debug -c HAP/HAPCharacteristicTypes.c -o Output/Linux-x86_64-pc-linux-gnu/Debug/HAP/HAPCharacteristicTypes.o
I get
Applications/Lock/Main.c:11:10: fatal error: 'HAPPlatform+Init.h' file not found
#include "HAPPlatform+Init.h"
^~~~~~~~~~~~~~~~~~~~
1 error generated.
Build/Makefile:162: recipe for target 'Output/Linux-x86_64-pc-linux-gnu/Debug/IP/Applications/Lock/Main.o' failed
There are three such files in the project :
$ find . -type f -name "HAPPlatform+*"
./PAL/Darwin/HAPPlatform+Init.h
./PAL/Mock/HAPPlatform+Init.h
./PAL/POSIX/HAPPlatform+Init.h
To make with mbedtls you also need libbsd: PAL/Crypto/MbedTLS/HAPMbedTLS.c add
and add -lbsd in Makefile.Linux LDFLAGS_Linux := -ldns_sd -lsqlite3 -pthread -lasound -lopus -lfaac -lm -lbsd
I have compiled successfully under ubuntu 16.04. The following is the note and hope it will help for the brave soul that is going to make under linux without using docker.
/HomeKitADK$ make TARGET=Linux all
use the following if you want to start over:
/HomeKitADK$ make TARGET=Linux clean
sudo apt-get install libavahi-compat-libdnssd-dev libopus-dev libfaac-dev
By default it will use OpenSSL implementation and you would need Openssl 1.1.0 and above so you would need to locally download the openssl 1.1.1 and compile and install it to /usr/local and then change the Build/Makefile
/HomeKitADK$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: Build/Makefile
Untracked files:
(use "git add
openssl-1.1.1c.tar.gz
openssl-1.1.1c/
no changes added to commit (use "git add" and/or "git commit -a") .~/work/HomeKitADK$ git diff diff --git a/Build/Makefile b/Build/Makefile index 129322f..e4e71f4 100644 --- a/Build/Makefile +++ b/Build/Makefile @@ -42,8 +42,13 @@ CFLAGS_Debug := -O0 -g -DHAP_LOG_LEVEL=$(LOG_LEVEL_Debug) -DHAP_TESTING CFLAGS_Test := -O0 -g -DHAP_LOG_LEVEL=$(LOG_LEVEL_Test) -DHAP_TESTING CFLAGS_Release := -O2 -g -DHAP_LOG_LEVEL=$(LOG_LEVEL_Release) -DHAP_DISABLE_ASSERTS=1 -DHAP_DISABLE_PRECONDITIONS=1
+ifeq ($(TARGET), Linux) +OPENSSL_PATH = /usr/local +MBEDTLS_PATH = $(firstword $(wildcard /usr/include/mbedtls) $(wildcard /usr/local/Cellar/mbedtls/)) +else OPENSSL_PATH = $(firstword $(wildcard /usr/local/Cellar/openssl@1.1/)) MBEDTLS_PATH = $(firstword $(wildcard /usr/include/mbedtls) $(wildcard /usr/local/Cellar/mbedtls/*)) +endif
-include Build/Makefile.$(PAL)
.~/work/HomeKitADK$
HomeKitADK$ make TARGET=Linux tools
HomeKitADK$ Tools/provision_raspi.sh --category 5 .HomeKitStore
================================================================================
Setup code: 112-11-449
Setup payload: X-HM://005279XVDPJES
================================================================================
qrencode not installed (brew install qrencode). Not generating QR code.
================================================================================
HomeKitADK$ Output/Linux-x86_64-pc-linux-gnu/Debug/IP/Applications/Lightbulb.OpenSSL
Open the Home app on the iPhone and 'Acme Light Bulb' would be showing up and add it manually with the setup code and then it should be good to play.
@Clovel while you can get HomeKit to compile on any Linux system, we use Docker explicitly to avoid the issues that you are seeing on installing dependencies for every flavor of linux.
I updated the documentation for Linux at https://github.com/apple/HomeKitADK/blob/master/Documentation/developing_with_adk.md#linux, which as you can see is just installing docker. With that and some of my recent fixes you should be able to just run make TARGET=Linux apps
to compile the code.
@aajain-com thanks for the clarification. Yet, some people cannot/don't want to use Docker for various reasons (VT-x disabled by IT dept., WSL, can't install because they aren't admins, or simply don't like Docker) but would still want to compile and contribute. Not my case on my main machine, but I have seen such cases in the wild.
I believe adding a "Dependencies" section for Linux & macOS in the doc wouldn't hurt.
Sure, PR welcome :)
Ok, I'll look into adding this in the documentation when #23 is done.
Should be fixed by #23 & #29 for the "non-docker" part.
Context
I am trying to compile the kit on a plain linux (Kubutnu 19.10 or WSL Ubuntu 18.04). This post and the following comments describe the errors I get in the process and what I am trying to do to fix them.
Errors
When simply cloning and building the kit w/
make
on a Linux system (Ubuntu WSL or Kubuntu 19.10), I get a compilation error on the following step :The error is the following :
The contents of the related file, Applications/Lock/Main.c, are the most peculiar :
There is indeed a
Main.c
in the parent directory of the file, that seems "normal".