NyaMisty / AltServer-Linux

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

Error when linking - undefined reference to dladdr, dlsym, etc. (SOLUTION) #7

Closed DragonOfSpace closed 2 years ago

DragonOfSpace commented 2 years ago

Hi,

When linking the application, LD reported the following errors

/usr/bin/ld: src/AltServerMain.cpp.o: in function `boost::stacktrace::detail::location_from_symbol::location_from_symbol(void const*)':
/usr/include/boost/stacktrace/detail/location_from_symbol.hpp:31: undefined reference to `dladdr'
/usr/bin/ld: src/AltServerMain.cpp.o: in function `boost::stacktrace::frame::name[abi:cxx11]() const':
/usr/include/boost/stacktrace/detail/frame_unwind.ipp:94: undefined reference to `dladdr'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): in function `dlfcn_globallookup':
(.text+0x17): undefined reference to `dlopen'
/usr/bin/ld: (.text+0x2a): undefined reference to `dlsym'
/usr/bin/ld: (.text+0x35): undefined reference to `dlclose'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): in function `dlfcn_pathbyaddr':
(.text+0x86): undefined reference to `dladdr'
/usr/bin/ld: (.text+0xf7): undefined reference to `dlerror'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): in function `dlfcn_bind_func':
(.text+0x407): undefined reference to `dlsym'
/usr/bin/ld: (.text+0x4d2): undefined reference to `dlerror'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): in function `dlfcn_load':
(.text+0x545): undefined reference to `dlopen'
/usr/bin/ld: (.text+0x5b9): undefined reference to `dlclose'
/usr/bin/ld: (.text+0x5f5): undefined reference to `dlerror'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): in function `dlfcn_unload':
(.text+0x6b8): undefined reference to `dlclose'
collect2: error: ld returned 1 exit status
make: *** [Makefile:89: AltServer] Error 1

SOLUTION: In the MAKEFILE, add the following flag to LDFLAGS (line 85) -ldl

So line 85 of the MAKEFILE should look like LDFLAGS = libraries/AltSign/AltSign.a -static -lssl -lcrypto -lpthread -lcorecrypto_static -lzip -lm -lz -lcpprest -lboost_system -lboost_filesystem -lstdc++ -lssl -lcrypto -luuid -ldl

Hope this information helps!