WerWolv / ImHex

🔍 A Hex Editor for Reverse Engineers, Programmers and people who value their retinas when working at 3 AM.
https://imhex.werwolv.net
GNU General Public License v2.0
42.37k stars 1.86k forks source link

Problem building on Ubuntu 20.04 #8

Closed popey closed 3 years ago

popey commented 3 years ago

Hi. Trying to build on a clean VM of Ubuntu 20.04. I'm building the latest stable (and master) and get the same.

[ 78%] Building CXX object CMakeFiles/ImHex.dir/libs/ImGui/source/imgui_draw.cpp.o
[ 81%] Building CXX object CMakeFiles/ImHex.dir/libs/ImGui/source/imgui_widgets.cpp.o
/root/parts/imhex/src/source/views/view_disassembler.cpp: In member function ‘virtual void hex::ViewDisassembler::createView()’:
/root/parts/imhex/src/source/views/view_disassembler.cpp:221:30: error: ‘CS_ARCH_M68K’ was not declared in this scope; did you mean ‘CS_ARCH_MAX’?
  221 |                         case CS_ARCH_M68K:
      |                              ^~~~~~~~~~~~
      |                              CS_ARCH_MAX
/root/parts/imhex/src/source/views/view_disassembler.cpp:222:30: error: ‘CS_ARCH_TMS320C64X’ was not declared in this scope
  222 |                         case CS_ARCH_TMS320C64X:
      |                              ^~~~~~~~~~~~~~~~~~
/root/parts/imhex/src/source/views/view_disassembler.cpp:223:30: error: ‘CS_ARCH_M680X’ was not declared in this scope; did you mean ‘CS_ARCH_MAX’?
  223 |                         case CS_ARCH_M680X:
      |                              ^~~~~~~~~~~~~
      |                              CS_ARCH_MAX
/root/parts/imhex/src/source/views/view_disassembler.cpp:224:30: error: ‘CS_ARCH_EVM’ was not declared in this scope; did you mean ‘CS_ARCH_ARM’?
  224 |                         case CS_ARCH_EVM:
      |                              ^~~~~~~~~~~
      |                              CS_ARCH_ARM
[ 84%] Building CXX object CMakeFiles/ImHex.dir/libs/ImGui/source/imgui_demo.cpp.o
make[2]: *** [CMakeFiles/ImHex.dir/build.make:323: CMakeFiles/ImHex.dir/source/views/view_disassembler.cpp.o] Error 1

I have the following dependencies installed:

      - libmagic-dev
      - libglfw3-dev
      - libssl-dev
      - llvm-10-dev
      - nlohmann-json3-dev
      - libcapstone-dev
      - python3-dev
      - pkg-config
      - libglm-dev
      - gcc-10
      - g++-10

Perhaps I'm missing something? Capstone related? The only thing I modified was to bodge it to use Python 3.8.5 rather than the explicitly specified 3.8.6 as Ubuntu doesn't have that. But I don't think that's related.

WerWolv commented 3 years ago

Hi! It's possible that Ubuntu has an older version of capstone than the one I'm using. It builds fine with Capstone 4.0.2 on Arch linux as well as on mingw. I'll add the version requirement to the cmake script

popey commented 3 years ago

Thanks for the quick reply! Yes, Ubuntu has capstone 3.x, so I guess I'll try building a newer one from source to fulfil that. Cheers!

xorhex commented 3 years ago

Had the same issues on Ubuntu. Posting here so hopefully helps other folks compiling on Ubuntu.

Now stuck at /usr/bin/ld: cannot find -lLLVMDemangle. llvm is installed but guessing I'm not using a new enough version.

[ 88%] Building CXX object CMakeFiles/ImHex.dir/libs/ImGui/source/imgui_demo.cpp.o
[ 91%] Building CXX object CMakeFiles/ImHex.dir/libs/ImGui/source/imgui_impl_opengl3.cpp.o
[ 94%] Building CXX object CMakeFiles/ImHex.dir/libs/ImGui/source/ImGuiFileBrowser.cpp.o
[ 97%] Building CXX object CMakeFiles/ImHex.dir/libs/ImGui/source/TextEditor.cpp.o
In file included from <redated>/opt/ImHex/source/lang/parser.cpp:3:
<redated>/opt/ImHex/include/helpers/utils.hpp: In instantiation of ‘std::string hex::format(const string&, Args ...) [with Args = {}; std::string = std::__cxx11::basic_string<char>]’:
<redated>/opt/ImHex/source/lang/parser.cpp:300:87:   required from here
<redated>/opt/ImHex/include/helpers/utils.hpp:25:32: warning: format not a string literal and no format arguments [-Wformat-security]
   25 |         ssize_t size = snprintf( nullptr, 0, format.c_str(), args ... );
      |                        ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<redated>/opt/ImHex/include/helpers/utils.hpp:31:17: warning: format not a string literal and no format arguments [-Wformat-security]
   31 |         snprintf(buffer.data(), size + 1, format.c_str(), args ...);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[100%] Linking CXX executable ImHex
/usr/bin/ld: cannot find -lLLVMDemangle
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/ImHex.dir/build.make:595: ImHex] Error 1
make[1]: *** [CMakeFiles/Makefile2:77: CMakeFiles/ImHex.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
mbitsnbites commented 3 years ago

It would be nice if this could build with out-of-the-box stuff on Ubuntu 20.04 (as it's a popular LTS), though it requires GCC 10 (Ubuntu has GCC 9) and I had to hack the CMake file to require Python 3.8.5 instead of 3.8.6. Still haven't pulled off a full build. Will keep trying.

Matir commented 3 years ago

@xorhex Neither Debian nor Ubuntu seems to ship LLVMDemangle as a shared library, only a static library. I'm trying to figure out a way to link against the static version instead.

Matir commented 3 years ago

If you change CMakeLists.txt like so, you should be able to build:

target_link_libraries(ImHex libglfw.so libmagic.so libcrypto.so libdl.so libcapstone.so ${LLVM_LIBRARY_DIRS}/libLLVMDemangle.a ${Python_LIBRARIES} nlohmann_json::nlohmann_json)

I haven't tested all the functionality yet, but it compiles and executes.

psifertex commented 3 years ago

Ubuntu 20.10 has capstone 4.0.1 which also fails.

Matir commented 3 years ago

Ubuntu 20.10 has capstone 4.0.1 which also fails.

Except, it doesn't really. For reasons I can't figure out, Debian and Ubuntu have packaged 3.0.5 and called it 4.0.1: https://packages.ubuntu.com/groovy/libcapstone3 shows 4.0.1+really+3.0.5-2 as the version string. I've never seen anything like it, but if you look at the source, it really is a 3.0.5 build.

mbitsnbites commented 3 years ago

When my projects have dependencies on likely-to-not-be-present packages, I usually make the related functionality optional in the project (e.g. if LLVM demangling is not available, disable demangling via a define from CMake). Could perhaps be a possibility for some of the deps.

krionical commented 3 years ago

So is this issue fixed? I'm having the problem mentioned above on Ubuntu 20.10--the weird updated but not really updated deal.

psifertex commented 3 years ago

yes, builds fine for me on a 20.10 box.

GeorgeIoak commented 3 years ago

I just tried on a fresh install of 20.04.1 and following this thread I'm still getting the "concepts error:

george@Ubuntu-20:~/ImHex/build$ make clean
george@Ubuntu-20:~/ImHex/build$ CC=gcc-10 CXX=g++-10 cmake ..
-- Configuring done
-- Generating done
-- Build files have been written to: /home/george/ImHex/build
george@Ubuntu-20:~/ImHex/build$ make -j 2
[  5%] Building CXX object CMakeFiles/ImHex.dir/source/window.cpp.o
[  5%] Building CXX object CMakeFiles/ImHex.dir/source/main.cpp.o
In file included from /home/george/ImHex/source/main.cpp:1:
/home/george/ImHex/include/window.hpp:3:10: fatal error: concepts: No such file or directory
    3 | #include <concepts>
      |          ^~~~~~~~~~
compilation terminated.
In file included from /home/george/ImHex/source/window.cpp:1:
/home/george/ImHex/include/window.hpp:3:10: fatal error: concepts: No such file or directory
    3 | #include <concepts>
      |          ^~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/ImHex.dir/build.make:63: CMakeFiles/ImHex.dir/source/main.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [CMakeFiles/ImHex.dir/build.make:76: CMakeFiles/ImHex.dir/source/window.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:77: CMakeFiles/ImHex.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
GeorgeIoak commented 3 years ago

I deleted the cloned directory and started over. I did have capstone downloaded, compiled and installed and I ran CC=gcc-10 CXX=g++-10 cmake .. and this time it compiled successfully so I'm not sure if it was the capstone, the change in cmake, or just user error.