radareorg / r2retdec

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

Failed to compile with BUILD_CUTTER_PLUGIN=ON on Linux: fatal error: rz_core.h: No such file or directory #29

Closed FreedomFrappa closed 2 years ago

FreedomFrappa commented 3 years ago

When built for Cutter, the build fails, without the BUILD_CUTTER_PLUGIN=ON build flag, it works. this was tested on archlinux and all the dependencies are installed. also encountered this issue on trisquel(ubuntu).

Requirements, versions: gcc (GCC) 10.2.0 cmake version 3.19.2 radare2 4.5.1

Installation steps:

git clone https://github.com/avast/retdec-r2plugin
cd retdec-r2plugin
mkdir build
cd build/
cmake .. -DCMAKE_INSTALL_PREFIX=~/.local -DBUILD_CUTTER_PLUGIN=ON
make -j 13

Cmake output:

$ cmake .. -DCMAKE_INSTALL_PREFIX=~/.local -DBUILD_CUTTER_PLUGIN=ON
-- The C compiler identification is GNU 10.2.0
-- The CXX compiler identification is GNU 10.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Setting build type to 'Release' as none was specified.
-- Found PkgConfig: /usr/bin/pkg-config (found version "1.7.3") 
-- Checking for one of the modules 'r_core'
-- Found Radare2: Radare2::libr  
-- Found PythonInterp: /usr/bin/python3 (found suitable version "3.9.1", minimum required is "3.4") 
-- Performing Test SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG
-- Performing Test SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG - Success
-- Capstone: using remote Capstone revision.
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Found ZLIB: /usr/lib/libz.so (found version "1.2.11") 
-- LLVM: using remote LLVM revision.
-- YARA: using remote YARA revision.
-- YaraMod: using remote YaraMod revision.
-- Found OpenSSL: /usr/lib/libcrypto.so (found suitable version "1.1.1i", minimum required is "1.0.1")  
-- -- Linking with /usr/lib/libstdc++fs.a library
-- Found Cutter: /home/XXX/XXX/retdec-r2plugin/build/_deps/cutter-src/src  
-- Linking with /usr/lib/libstdc++fs.a library
-- Configuring done
-- Generating done
-- Build files have been written to: /home/XXX/XXX/retdec-r2plugin/build

Make build output(error):

$make -j 13
[  2%] Built target utils
[  3%] Built target yara
[  3%] Built target pdbparser
[  4%] Built target yaramod-project
[  6%] Built target pelib
[  7%] Built target capstone-project
[  7%] Built target tinyxml2
[  8%] Built target llvm-project
[ 10%] Built target common
[ 13%] Built target ctypes
[ 13%] Built target idr2pat
[ 13%] Built target ar-extractor
[ 14%] Built target yaracpp
[ 14%] Built target macho-extractor
[ 15%] Built target ctypesparser
[ 17%] Built target serdes
[ 17%] Built target ar-extractortool
[ 18%] Built target capstone2llvmir
[ 18%] Built target macho-extractortool
[ 22%] Built target demangler
[ 23%] Built target config
[ 31%] Built target fileformat
[ 31%] Built target getsig
[ 32%] Built target patterngen
[ 34%] Built target loader
[ 35%] Built target cpdetect
[ 35%] Built target pat2yara
[ 35%] Built target bin2pat
[ 36%] Built target unpacker
[ 36%] Built target stacofin
[ 37%] Built target rtti-finder
[ 37%] Built target debugformat
[ 37%] Built target stacofintool
[ 39%] Built target unpackertool
[ 72%] Built target llvmir2hll
[ 73%] Built target main
[ 85%] Built target fileinfo
[ 98%] Built target bin2llvmir
[ 98%] Built target retdec
[ 98%] Automatic MOC and UIC for target r2retdec_cutter
[ 98%] Built target retdec-decompiler
[ 99%] Built target core_retdec
[ 99%] Built target r2retdec_cutter_autogen
[ 99%] Building CXX object src/cutter-plugin/CMakeFiles/r2retdec_cutter.dir/r2retdec_cutter_autogen/mocs_compilation.cpp.o
[ 99%] Building CXX object src/cutter-plugin/CMakeFiles/r2retdec_cutter.dir/core_plugin.cpp.o
In file included from /home/user/XXX/retdec-r2plugin/build/_deps/cutter-src/src/widgets/CutterDockWidget.h:4,
                 from /home/XXX/XXX/retdec-r2plugin/build/_deps/cutter-src/src/plugins/CutterPlugin.h:6,
                 from /home/XXX/XXX/retdec-r2plugin/build/src/cutter-plugin/r2retdec_cutter_autogen/4NLJWMO7SH/../../../../../include/cutter-plugin/core_plugin.h:12,
                 from /home/XXX/XXX/retdec-r2plugin/build/src/cutter-plugin/r2retdec_cutter_autogen/4NLJWMO7SH/moc_core_plugin.cpp:10,
                 from /home/XXX/XXX/retdec-r2plugin/build/src/cutter-plugin/r2retdec_cutter_autogen/mocs_compilation.cpp:2:
/home/user/Apps/retdec-r2plugin/build/_deps/cutter-src/src/core/CutterCommon.h:8:10: fatal error: rz_core.h: No such file or directory
    8 | #include "rz_core.h"
      |          ^~~~~~~~~~~
compilation terminated.
make[2]: *** [src/cutter-plugin/CMakeFiles/r2retdec_cutter.dir/build.make:82: src/cutter-plugin/CMakeFiles/r2retdec_cutter.dir/r2retdec_cutter_autogen/mocs_compilation.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
In file included from /home/XXX/XXX/retdec-r2plugin/build/_deps/cutter-src/src/widgets/CutterDockWidget.h:4,
                 from /home/XXX/XXX/retdec-r2plugin/build/_deps/cutter-src/src/plugins/CutterPlugin.h:6,
                 from /home/XXX/XXX/retdec-r2plugin/include/cutter-plugin/core_plugin.h:12,
                 from /home/XXX/XXX/retdec-r2plugin/src/cutter-plugin/core_plugin.cpp:9:
/home/user/Apps/retdec-r2plugin/build/_deps/cutter-src/src/core/CutterCommon.h:8:10: fatal error: rz_core.h: No such file or directory
    8 | #include "rz_core.h"
      |          ^~~~~~~~~~~
compilation terminated.
make[2]: *** [src/cutter-plugin/CMakeFiles/r2retdec_cutter.dir/build.make:95: src/cutter-plugin/CMakeFiles/r2retdec_cutter.dir/core_plugin.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:2542: src/cutter-plugin/CMakeFiles/r2retdec_cutter.dir/all] Error 2
make: *** [Makefile:149: all] Error 2

Afterwards rizin-git was installed, and it still did not work, same error. Package: https://aur.archlinux.org/packages/rizin-git/

Rizin version, on second attempt: rizin 0.1.0-git 25276 commit: 40a29cba29ebb58a15ca372a765be56e5d19d5ac

audibleblink commented 3 years ago

Same outcome for me. Rizin-git 0.2.0. You ever get this working @FreedomFrappa?

JamesClarke7283 commented 2 years ago

When compiling under iaito i get this error. Of course i changed the flags to reflect the iaito plugin build.

/retdec-r2plugin/include/r2plugin/r2retdec.h:10:10: fatal error: r_util/r_annotated_code.h: No such file or directory

I installed the regular radare2 from the arch repositories. it could be because i am not on the latest version of radare2. But it should just work. Maybe bundleing radare2 with iaito would work. but i dont know.

there should be a package manager like with radare2 itself but for the iaito/Cutter GUI, like a plugin library.

ghost commented 2 years ago

r2retdec is outdated, unusable now as r2 plugin too

JamesClarke7283 commented 2 years ago

r2retdec is outdated, unusable now as r2 plugin too

Might have something to do with this: https://github.com/radareorg/r2retdec/pull/40

But my issue may be seperate i am not sure. if r_util/r_annotated_code.h is new, then its likely due to being outdated.

trufae commented 2 years ago

The last time i tried to get r2retdec to work with r2 retdec was abandoned, and it was requiring some work in their side to make it work again because of incompatibilities with the version of capstone (cs4 vs cs5) and their linking was done wrong.

iaito doesnt have plugins, because it just uses r2 plugins, the code involved is useless and will be removed.

Their authors stopped responding me a year ago, but seems like there are new commits these days and i assume they fixed. so maybe if im bored i'll pick it up, but i'm already maintaining over 9000 projects alone and it would be great if someone could help on maintaining or contributing to get it working again.