radareorg / r2retdec

RetDec plugin for Radare2
https://retdec.com/
MIT License
125 stars 24 forks source link

Support For Termux #25

Open apkunpacker opened 4 years ago

apkunpacker commented 4 years ago

Getting same issue as https://github.com/android/ndk/issues/609 when following build instructions as per as readme

Linux and MacOS: cd retdec-r2plugin mkdir build && cd build cmake .. -DCMAKE_INSTALL_PREFIX= make -jN (N is the number of processes to use for parallel build, typically number of cores + 1 gives fastest compilation time) make install

and below error occur on make -jN step . i am using make -j9

/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: CMakeFiles/ar-extractortool.dir/ar_extractor.cpp.o: in function std::__ndk1::__fs::filesystem::is_regular_file(std::__ndk1::__fs::filesystem::path const&)': /data/data/com.termux/files/usr/include/c++/v1/filesystem:1721: undefined reference tostd::ndk1::fs::filesystem::status(std::ndk1::fs::filesystem::path const&, std::ndk1::error_code)' /data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: ../ar-extractor/libretdec-ar-extractor.a(archive_wrapper.cpp.o): in function std::__ndk1::__fs::filesystem::is_directory(std::__ndk1::__fs::filesystem::path const&)': /data/data/com.termux/files/usr/include/c++/v1/filesystem:1686: undefined reference tostd::ndk1::fs::filesystem::status(std::ndk1::fs::filesystem::path const&, std::ndk1::error_code)' clang-10: error: linker command failed with exit code 1 (use -v to see invocation) make[2]: [_deps/retdec-build/src/ar-extractortool/CMakeFiles/ar-extractortool.dir/build.make:142: _deps/retdec-build/src/ar-extractortool/retdec-ar-extractor] Error 1 make[1]: [CMakeFiles/Makefile2:1312: _deps/retdec-build/src/ar-extractortool/CMakeFiles/ar-extractortool.dir/all] Error 2 make[1]: *** Waiting for unfinished jobs....

Screenshot_2020-11-08-08-19-59-03

xkubov commented 3 years ago

Hi, I do not know much about developing with android/ndk but the error might be solved by linking stc++fs manually. Do you see following message at the top of the cmake output? -- Library stdc++fs NOT found -> linking utils without stdc++fs library

We tried to solve this in RetDec by linking stdc++fs to the library on any UNIX machine that is not APPLE (clang does not have such a library). Can you check if you can compile RetDec separately (https://github.com/avast/retdec)? If yes, we can easily reflect this to the plugin.

apkunpacker commented 3 years ago

Do you see following message at the top of the cmake output?

-- Library stdc++fs NOT found -> linking utils without stdc++fs library

yeah exactly i see this . how can i fix it

xkubov commented 3 years ago

The easiest solution, for now, would be for you to locate stdc++fs on your system. When you locate this library, invoke cmake command again with the parameter -DCMAKE_LIBRARY_PATH=${PATH_TO_FILESTSTEM_DIR}.

For example on ubuntu with GCC 7 the filesystem is located in /usr/lib/gcc/x86_64-linux-gnu/7/libstdc++fs.a, so the parameter for cmake would look like: cmake -DCMAKE_LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/7/.

If the problem is caused by not linking stdc++fs this should probably solve the problem.

apkunpacker commented 3 years ago

on termux gcc support is dropped . may you provide prebuilt core_retdec.so for arm64 android

radare commented 2 years ago

I think libstdc++fs is experimental for the ndk, so probably the best way to go would be to make retdec not depend on this, but i dont know how hard would be to remove this dependency.