NyaMisty / AltServer-Linux

AltServer for AltStore, but on-device
GNU Affero General Public License v3.0
946 stars 73 forks source link

Can not compiled under aarch64 #23

Closed D-06 closed 2 years ago

D-06 commented 2 years ago

make -C libraries/AltSign make[1]: Entering directory '/home/interland/AltServer-Linux/libraries/AltSign' clang++ -Iminizip -I../libplist/include -I. -mno-sse -std=c++17 -o Team.cpp.o -c Team.cpp clang: warning: argument unused during compilation: '-mno-sse' [-Wunused-command-line-argument] In file included from Team.cpp:9: ./Team.hpp:15:10: fatal error: 'cpprest/http_client.h' file not found

include <cpprest/http_client.h>

     ^~~~~~~~~~~~~~~~~~~~~~~

1 error generated. make[1]: [Makefile:18: Team.cpp.o] Error 1 make[1]: Leaving directory '/home/interland/AltServer-Linux/libraries/AltSign' make: [Makefile:83: lib_AltSign] Error 2

deatondg commented 2 years ago

As described in the README, you must install cpprest. In Ubuntu, use sudo apt install libcpprest-dev. I have not been able to fix the issues after this.

D-06 commented 2 years ago

As described in the README, you must install cpprest. In Ubuntu, use sudo apt install libcpprest-dev. I have not been able to fix the issues after this.

? cc: error: unrecognized command line option ‘-mno-default’ make: *** [Makefile:13: src/muslfix.c.o] Error 1

deatondg commented 2 years ago

To fix that one, I edited the Makefile on line 13 and removed -mno-default. I am not entirely sure what that option is even supposed to do.

D-06 commented 2 years ago

/bin/ld: cannot find -lcpprest /bin/ld: /usr/lib/gcc/aarch64-linux-gnu/9/../../../aarch64-linux-gnu/libcrypto.a(dso_dlfcn.o): in function dlfcn_globallookup': (.text+0x1c): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /bin/ld: libraries/miniupnp.a(connecthostport.c.o): in functionconnecthostport': /root/AltServer-Linux/libraries/miniupnpc/connecthostport.c:183: warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /bin/ld: /usr/lib/gcc/aarch64-linux-gnu/9/../../../aarch64-linux-gnu/libcrypto.a(b_sock.o): in function `BIO_gethostbyname': (.text+0x78): warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking collect2: error: ld returned 1 exit status make: *** [Makefile:89: AltServer] Error 1

deatondg commented 2 years ago

Remove -static from line 85 of the Makefile. I guess aarch64 linux doesn’t support dynamic linking against libcrypto? That should also fix your issue with /bin/ld: cannot find -lcpprest.

Also, some GitHub advice: use ``` (three back-ticks) before and after pasting your log messages for better readability. It should look like

make -C libraries/AltSign make[1]: Entering directory '/home/interland/AltServer-Linux/libraries/AltSign' clang++ -Iminizip -I../libplist/include -I. -mno-sse -std=c++17 -o Team.cpp.o -c Team.cpp clang: warning: argument unused during compilation: '-mno-sse' [-Wunused-command-line-argument] In file included from Team.cpp:9: ./Team.hpp:15:10: fatal error: 'cpprest/http_client.h' file not found

include <cpprest/http_client.h>

^~~~~~~ 1 error generated. make[1]: [Makefile:18: Team.cpp.o] Error 1 make[1]: Leaving directory '/home/interland/AltServer-Linux/libraries/AltSign' make: [Makefile:83: lib_AltSign] Error 2

which will render as

make -C libraries/AltSign
make[1]: Entering directory '/home/interland/AltServer-Linux/libraries/AltSign'
clang++ -Iminizip -I../libplist/include -I. -mno-sse -std=c++17 -o Team.cpp.o -c Team.cpp
clang: warning: argument unused during compilation: '-mno-sse' [-Wunused-command-line-argument]
In file included from Team.cpp:9:
./Team.hpp:15:10: fatal error: 'cpprest/http_client.h' file not found
#include <cpprest/http_client.h>
^~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make[1]: *** [Makefile:18: Team.cpp.o] Error 1
make[1]: Leaving directory '/home/interland/AltServer-Linux/libraries/AltSign'
make: *** [Makefile:83: lib_AltSign] Error 2

Hopefully we’ll get this running soon. :)

D-06 commented 2 years ago

It taking so long to make

/bin/ld: src/AltServerMain.cpp.o: undefined reference to symbol 'dladdr@@GLIBC_2.17'
/bin/ld: /lib/aarch64-linux-gnu/libdl.so.2: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: *** [Makefile:89: AltServer] Error 1
deatondg commented 2 years ago

Try adding -ldl to line 85 of the Makefile

D-06 commented 2 years ago

It takes me to another error

/bin/ld: libraries/AltSign/AltSign.a(Team.cpp.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `_ZNSt8ios_base4InitD1Ev@@GLIBCXX_3.4' which may bind externally can not be used when making a shared object; recompile with -fPIC
/bin/ld: libraries/AltSign/AltSign.a(Team.cpp.o)(.text.startup+0x14): unresolvable R_AARCH64_ADR_PREL_PG_HI21 relocation against symbol `_ZNSt8ios_base4InitD1Ev@@GLIBCXX_3.4'
/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
make: *** [Makefile:89: AltServer] Error 1
deatondg commented 2 years ago

Run make clean and also run make clean in the libraries/AltSign directory. Replace -mno-sse with -fPIC in libraries/AltSign/Makefile. Then try to compile again.

D-06 commented 2 years ago

Run make clean and also run make clean in the libraries/AltSign directory. Replace -mno-sse with -fPIC in libraries/AltSign/Makefile. Then try to compile again.

It works finally

deatondg commented 2 years ago

Great, I am glad you got it working! You may want to leave this issue open with the title “Cannot compile under aarch64” or something similar. Ideally, these changes will be integrated into the build process (perhaps conditionally based on architecture). In my opinion, it is still an issue that these changes are required.

NyaMisty commented 2 years ago

You shouldn't compile it using anything from GNU except gcc.. The OpenSSL's libcrypto uses nss which cannot be statically linked.