Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac support request #32

Closed
benjioh5 opened this issue Dec 5, 2020 · 29 comments
Closed

Mac support request #32

benjioh5 opened this issue Dec 5, 2020 · 29 comments
Assignees

Comments

@benjioh5
Copy link

benjioh5 commented Dec 5, 2020

Is there any plan to support mac os?

I've tried some build and got this.

[  2%] Building CXX object CMakeFiles/ImHex.dir/source/window.cpp.o
[  5%] Building CXX object CMakeFiles/ImHex.dir/source/main.cpp.o
[ 13%] Building CXX object CMakeFiles/ImHex.dir/source/helpers/crypto.cpp.o
[ 13%] Building CXX object CMakeFiles/ImHex.dir/source/helpers/patches.cpp.o
[ 13%] Building CXX object CMakeFiles/ImHex.dir/source/helpers/math_evaluator.cpp.o
[ 16%] Building CXX object CMakeFiles/ImHex.dir/source/helpers/loader_script_handler.cpp.o
[ 19%] Building CXX object CMakeFiles/ImHex.dir/source/lang/lexer.cpp.o
[ 22%] Building CXX object CMakeFiles/ImHex.dir/source/providers/file_provider.cpp.o
[ 27%] Building CXX object CMakeFiles/ImHex.dir/source/views/view_hexeditor.cpp.o
[ 27%] Building CXX object CMakeFiles/ImHex.dir/source/lang/evaluator.cpp.o
[ 33%] Building CXX object CMakeFiles/ImHex.dir/source/views/view_pattern.cpp.o
[ 36%] Building CXX object CMakeFiles/ImHex.dir/source/views/view_pattern_data.cpp.o
[ 36%] Building CXX object CMakeFiles/ImHex.dir/source/views/view_hashes.cpp.o
[ 38%] Building CXX object CMakeFiles/ImHex.dir/source/views/view_information.cpp.o
[ 41%] Building CXX object CMakeFiles/ImHex.dir/source/views/view_help.cpp.o
[ 44%] Building CXX object CMakeFiles/ImHex.dir/source/views/view_tools.cpp.o
[ 47%] Building CXX object CMakeFiles/ImHex.dir/source/views/view_strings.cpp.o
In file included from /Users/benjioh5/Coding/hobby/4_Contribution/ImHex/source/window.cpp:1:
/Users/benjioh5/Coding/hobby/4_Contribution/ImHex/include/window.hpp:3:10: fatal error: 'concepts' file
      not found
#include <concepts>
         ^~~~~~~~~~
[ 50%] Building CXX object CMakeFiles/ImHex.dir/source/views/view_disassembler.cpp.o
[ 52%] Building CXX object CMakeFiles/ImHex.dir/source/views/view_bookmarks.cpp.o
[ 58%] Building CXX object CMakeFiles/ImHex.dir/source/views/view_patches.cpp.o
[ 58%] Building CXX object CMakeFiles/ImHex.dir/source/views/view_data_inspector.cpp.o
In file included from /Users/benjioh5/Coding/hobby/4_Contribution/ImHex/source/main.cpp:1:
/Users/benjioh5/Coding/hobby/4_Contribution/ImHex/include/window.hpp:3:10: fatal error: 'concepts' file
      not found
#include <concepts>
         ^~~~~~~~~~
In file included from /Users/benjioh5/Coding/hobby/4_Contribution/ImHex/source/providers/file_provider.cpp:1:
In file included from /Users/benjioh5/Coding/hobby/4_Contribution/ImHex/include/providers/file_provider.hpp:3:
/Users/benjioh5/Coding/hobby/4_Contribution/ImHex/include/providers/provider.hpp:6:10: fatal error:
      'concepts' file not found
#include <concepts>
         ^~~~~~~~~~
In file included from /Users/benjioh5/Coding/hobby/4_Contribution/ImHex/source/lang/evaluator.cpp:1:
In file included from /Users/benjioh5/Coding/hobby/4_Contribution/ImHex/include/lang/evaluator.hpp:5:
/Users/benjioh5/Coding/hobby/4_Contribution/ImHex/include/providers/provider.hpp:6:10: fatal error:
      'concepts' file not found
#include <concepts>
         ^~~~~~~~~~
/Users/benjioh5/Coding/hobby/4_Contribution/ImHex/source/helpers/patches.cpp:3:10: fatal error:
      'concepts' file not found
#include <concepts>
         ^~~~~~~~~~
In file included from /Users/benjioh5/Coding/hobby/4_Contribution/ImHex/source/helpers/crypto.cpp:3:
/Users/benjioh5/Coding/hobby/4_Contribution/ImHex/include/providers/provider.hpp:6:10: fatal error:
      'concepts' file not found
#include <concepts>
         ^~~~~~~~~~
/Users/benjioh5/Coding/hobby/4_Contribution/ImHex/source/lang/lexer.cpp:24:10: error: no template named
      'optional' in namespace 'std'
    std::optional<u64> parseInt(std::string_view string) {
    ~~~~~^
1 error generated.
make[2]: *** [CMakeFiles/ImHex.dir/source/helpers/patches.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
/Users/benjioh5/Coding/hobby/4_Contribution/ImHex/source/lang/lexer.cpp:234:41: error: no matching
      constructor for initialization of 'std::string_view' (aka 'basic_string_view<char>')
                auto integer = parseInt(std::string_view(&code[offset], end));
                                        ^                ~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string_view:229:5: note:
      candidate constructor not viable: no known conversion from 'char *' to
      'std::__1::basic_string_view::size_type' (aka 'unsigned long') for 2nd argument; dereference the
      argument with *
    basic_string_view(const _CharT* __s, size_type __len) _NOEXCEPT
    ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string_view:223:5: note:
      candidate constructor not viable: requires 1 argument, but 2 were provided
    basic_string_view(const basic_string_view&) _NOEXCEPT = default;
    ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string_view:238:5: note:
      candidate constructor not viable: requires single argument '__s', but 2 arguments were provided
    basic_string_view(const _CharT* __s)
    ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string_view:220:5: note:
      candidate constructor not viable: requires 0 arguments, but 2 were provided
    basic_string_view() _NOEXCEPT : __data (nullptr), __size(0) {}
    ^
1 error generated.
make[2]: *** [CMakeFiles/ImHex.dir/source/providers/file_provider.cpp.o] Error 1
In file included from /Users/benjioh5/Coding/hobby/4_Contribution/ImHex/source/views/view_patches.cpp:3:
/Users/benjioh5/Coding/hobby/4_Contribution/ImHex/include/providers/provider.hpp:6:10: fatal error:
      'concepts' file not found
#include <concepts>
         ^~~~~~~~~~
In file included from /Users/benjioh5/Coding/hobby/4_Contribution/ImHex/source/views/view_strings.cpp:3:
/Users/benjioh5/Coding/hobby/4_Contribution/ImHex/include/providers/provider.hpp:6:10: fatal error:
      'concepts' file not found
#include <concepts>
         ^~~~~~~~~~
In file included from /Users/benjioh5/Coding/hobby/4_Contribution/ImHex/source/views/view_data_inspector.cpp:3:
/Users/benjioh5/Coding/hobby/4_Contribution/ImHex/include/providers/provider.hpp:6:10: fatal error:
      'concepts' file not found
#include <concepts>
         ^~~~~~~~~~
In file included from /Users/benjioh5/Coding/hobby/4_Contribution/ImHex/source/helpers/loader_script_handler.cpp:5:
/Users/benjioh5/Coding/hobby/4_Contribution/ImHex/include/providers/provider.hpp:6:10: fatal error:
      'concepts' file not found
#include <concepts>
         ^~~~~~~~~~
In file included from /Users/benjioh5/Coding/hobby/4_Contribution/ImHex/source/views/view_information.cpp:3:
/Users/benjioh5/Coding/hobby/4_Contribution/ImHex/include/providers/provider.hpp:6:10: fatal error:
      'concepts' file not found
#include <concepts>
         ^~~~~~~~~~
In file included from /Users/benjioh5/Coding/hobby/4_Contribution/ImHex/source/views/view_hashes.cpp:3:
/Users/benjioh5/Coding/hobby/4_Contribution/ImHex/include/providers/provider.hpp:6:10: fatal error:
      'concepts' file not found
#include <concepts>
         ^~~~~~~~~~
In file included from /Users/benjioh5/Coding/hobby/4_Contribution/ImHex/source/views/view_disassembler.cpp:3:
/Users/benjioh5/Coding/hobby/4_Contribution/ImHex/include/providers/provider.hpp:6:10: fatal error:
      'concepts' file not found
#include <concepts>
         ^~~~~~~~~~
In file included from /Users/benjioh5/Coding/hobby/4_Contribution/ImHex/source/views/view_pattern_data.cpp:1:
In file included from /Users/benjioh5/Coding/hobby/4_Contribution/ImHex/include/views/view_pattern_data.hpp:7:
In file included from /Users/benjioh5/Coding/hobby/4_Contribution/ImHex/include/lang/pattern_data.hpp:7:
/Users/benjioh5/Coding/hobby/4_Contribution/ImHex/libs/ImGui/include/imgui_memory_editor.h:230:23: warning:
      flag ' ' results in undefined behavior with 'c' conversion specifier [-Wformat]
        ImGui::Text("% *c   ", s.AddrDigitsCount, ' ');
                     ~^~~
/Users/benjioh5/Coding/hobby/4_Contribution/ImHex/source/helpers/math_evaluator.cpp:10:10: fatal error:
      'numbers' file not found
#include <numbers>
         ^~~~~~~~~
1 error generated.
In file included from /Users/benjioh5/Coding/hobby/4_Contribution/ImHex/source/views/view_pattern_data.cpp:1:
In file included from /Users/benjioh5/Coding/hobby/4_Contribution/ImHex/include/views/view_pattern_data.hpp:7:
In file included from /Users/benjioh5/Coding/hobby/4_Contribution/ImHex/include/lang/pattern_data.hpp:9:
/Users/benjioh5/Coding/hobby/4_Contribution/ImHex/include/providers/provider.hpp:6:10: fatal error:
      'concepts' file not found
#include <concepts>
         ^~~~~~~~~~
1 error generated.
In file included from /Users/benjioh5/Coding/hobby/4_Contribution/ImHex/source/views/view_bookmarks.cpp:3:
/Users/benjioh5/Coding/hobby/4_Contribution/ImHex/include/providers/provider.hpp:6:10: fatal error:
      'concepts' file not found
#include <concepts>
         ^~~~~~~~~~
make[2]: *** [CMakeFiles/ImHex.dir/source/helpers/crypto.cpp.o] Error 1
make[2]: *** [CMakeFiles/ImHex.dir/source/helpers/math_evaluator.cpp.o] Error 1
In file included from /Users/benjioh5/Coding/hobby/4_Contribution/ImHex/source/views/view_hexeditor.cpp:1:
In file included from /Users/benjioh5/Coding/hobby/4_Contribution/ImHex/include/views/view_hexeditor.hpp:6:
/Users/benjioh5/Coding/hobby/4_Contribution/ImHex/libs/ImGui/include/imgui_memory_editor.h:230:23: warning:
      flag ' ' results in undefined behavior with 'c' conversion specifier [-Wformat]
        ImGui::Text("% *c   ", s.AddrDigitsCount, ' ');
                     ~^~~
In file included from /Users/benjioh5/Coding/hobby/4_Contribution/ImHex/source/views/view_help.cpp:1:
In file included from /Users/benjioh5/Coding/hobby/4_Contribution/ImHex/include/views/view_help.hpp:7:
In file included from /Users/benjioh5/Coding/hobby/4_Contribution/ImHex/include/lang/pattern_data.hpp:7:
/Users/benjioh5/Coding/hobby/4_Contribution/ImHex/libs/ImGui/include/imgui_memory_editor.h:230:23: warning: 2 errors generated.

      flag ' ' results in undefined behavior with 'c' conversion specifier [-Wformat]
        ImGui::Text("% *c   ", s.AddrDigitsCount, ' ');
                     ~^~~
1 error generated.
make[2]: *** [CMakeFiles/ImHex.dir/source/lang/lexer.cpp.o] Error 1
1 error generated.
make[2]: *** [CMakeFiles/ImHex.dir/source/views/view_strings.cpp.o] Error 1
make[2]: *** [CMakeFiles/ImHex.dir/source/views/view_data_inspector.cpp.o] Error 1
1 error generated.
In file included from /Users/benjioh5/Coding/hobby/4_Contribution/ImHex/source/views/view_help.cpp:1:
In file included from /Users/benjioh5/Coding/hobby/4_Contribution/ImHex/include/views/view_help.hpp:7:
In file included from /Users/benjioh5/Coding/hobby/4_Contribution/ImHex/include/lang/pattern_data.hpp:9:
/Users/benjioh5/Coding/hobby/4_Contribution/ImHex/include/providers/provider.hpp:6:10: fatal error:
      'concepts' file not found
#include <concepts>
         ^~~~~~~~~~
1 error generated.
make[2]: *** [CMakeFiles/ImHex.dir/source/views/view_patches.cpp.o] Error 1
make[2]: *** [CMakeFiles/ImHex.dir/source/views/view_hashes.cpp.o] Error 1
1 error generated.
1 error generated.
1 error generated.
make[2]: *** [CMakeFiles/ImHex.dir/source/window.cpp.o] Error 1
make[2]: *** [CMakeFiles/ImHex.dir/source/views/view_bookmarks.cpp.o] Error 1
make[2]: *** [CMakeFiles/ImHex.dir/source/views/view_disassembler.cpp.o] Error 1
In file included from /Users/benjioh5/Coding/hobby/4_Contribution/ImHex/source/views/view_pattern.cpp:1:
In file included from /Users/benjioh5/Coding/hobby/4_Contribution/ImHex/include/views/view_pattern.hpp:6:
In file included from /Users/benjioh5/Coding/hobby/4_Contribution/ImHex/include/lang/pattern_data.hpp:7:
/Users/benjioh5/Coding/hobby/4_Contribution/ImHex/libs/ImGui/include/imgui_memory_editor.h:230:23: warning:
      flag ' ' results in undefined behavior with 'c' conversion specifier [-Wformat]
        ImGui::Text("% *c   ", s.AddrDigitsCount, ' ');
                     ~^~~
In file included from /Users/benjioh5/Coding/hobby/4_Contribution/ImHex/source/views/view_pattern.cpp:1:
In file included from /Users/benjioh5/Coding/hobby/4_Contribution/ImHex/include/views/view_pattern.hpp:6:
In file included from /Users/benjioh5/Coding/hobby/4_Contribution/ImHex/include/lang/pattern_data.hpp:9:
/Users/benjioh5/Coding/hobby/4_Contribution/ImHex/include/providers/provider.hpp:6:10: fatal error:
      'concepts' file not found
#include <concepts>
         ^~~~~~~~~~
1 error generated.
make[2]: *** [CMakeFiles/ImHex.dir/source/lang/evaluator.cpp.o] Error 1
1 error generated.
make[2]: *** [CMakeFiles/ImHex.dir/source/views/view_information.cpp.o] Error 1
1 warning and 1 error generated.
make[2]: *** [CMakeFiles/ImHex.dir/source/views/view_pattern_data.cpp.o] Error 1
1 error generated.
1 warning and 1 error generated.
In file included from /Users/benjioh5/Coding/hobby/4_Contribution/ImHex/source/views/view_tools.cpp:7:
/Users/benjioh5/Coding/hobby/4_Contribution/ImHex/include/providers/provider.hpp:6:10: fatal error:
      'concepts' file not found
#include <concepts>
         ^~~~~~~~~~
make[2]: *** [CMakeFiles/ImHex.dir/source/helpers/loader_script_handler.cpp.o] Error 1
make[2]: *** [CMakeFiles/ImHex.dir/source/views/view_help.cpp.o] Error 1
1 error generated.
In file included from /Users/benjioh5/Coding/hobby/4_Contribution/ImHex/source/views/view_hexeditor.cpp:1:
In file included from /Users/benjioh5/Coding/hobby/4_Contribution/ImHex/include/views/view_hexeditor.hpp:13:
In file included from /Users/benjioh5/Coding/hobby/4_Contribution/ImHex/include/lang/pattern_data.hpp:9:
/Users/benjioh5/Coding/hobby/4_Contribution/ImHex/include/providers/provider.hpp:6:10: fatal error:
      'concepts' file not found
#include <concepts>
         ^~~~~~~~~~
make[2]: *** [CMakeFiles/ImHex.dir/source/views/view_tools.cpp.o] Error 1
1 error generated.
make[2]: *** [CMakeFiles/ImHex.dir/source/main.cpp.o] Error 1
1 warning and 1 error generated.
make[2]: *** [CMakeFiles/ImHex.dir/source/views/view_hexeditor.cpp.o] Error 1
1 warning and 1 error generated.
make[2]: *** [CMakeFiles/ImHex.dir/source/views/view_pattern.cpp.o] Error 1
make[1]: *** [CMakeFiles/ImHex.dir/all] Error 2
make: *** [all] Error 2

I think Apple clang 12.0.0 doest not support C++17 std::optional and C++20 features fully. Is there any support plan on Mac OS after apple clang supports C++20 featrues?

@marysaka
Copy link
Contributor

marysaka commented Dec 5, 2020

@benjioh5 I personally plan to look into supporting clang when it could be done ^^

@WerWolv
Copy link
Owner

WerWolv commented Dec 6, 2020

Latest commit fixes some of the issues with building on MacOS. If possible, please test it with a appropriate C++20 compiler.

@the-wondersmith
Copy link

the-wondersmith commented Dec 6, 2020

Latest commit fixes some of the issues with building on MacOS. If possible, please test it with a appropriate C++20 compiler.

@WerWolv Total coincidence, but I was trying to get ImHex to compile last night and left everything up to come back to it this morning. There are fewer errors with the new changes, but it still fails to compile. I made a gist of the output here.

I did have to add some environment variables so that cmake would correctly find all the packages it was looking for, but all the dependencies are available via Homebrew. The extra environment variables I used are:

export CC=/usr/local/opt/llvm/bin/clang
export CPP=/usr/local/opt/llvm/bin/clang++

export PATH="/usr/local/opt/llvm/bin:$PATH"
export CPPFLAGS="-I/usr/local/opt/llvm/include -I/usr/local/opt/openssl/include"
export LDFLAGS="-L/usr/local/opt/openssl/lib -L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib"
export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig"

Oh! And in case it's relevant, I also have the OpenSSL / libcrypto libraries symlinked to /usr/local/lib thusly:

for lib in $(ls /usr/local/Cellar/openssl\@1.1/1.1.1h/lib/lib*); do ln -s $lib /usr/local/lib/; done

Does this help at all?

@WerWolv
Copy link
Owner

WerWolv commented Dec 6, 2020

Okay, look like it's all on Apple / clang now. All those errors are just XXXX is unavailable: introduced in macOS 10.15. Once clang updates, this should work then :)

@benjioh5
Copy link
Author

benjioh5 commented Dec 6, 2020

@the-wondersmith I did same thing on my environment. openssl@1.1 or libressl works fine now.

this is my fish setting.

# apple llvm to homebrew llvm
set -gx LDFLAGS "-L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib"
set -gx CPPFLAGS "-I/usr/local/opt/llvm/include"
set -g fish_user_paths "/usr/local/opt/llvm/bin" $fish_user_paths

# add openssl@1.1
#set -gx LDFLAGS "-L/usr/local/opt/openssl@1.1/lib"
#set -gx CPPFLAGS "-I/usr/local/opt/openssl@1.1/include"
#set -gx PKG_CONFIG_PATH "/usr/local/opt/openssl@1.1/lib/pkgconfig"

# add libressl
set -gx LDFLAGS "-L/usr/local/opt/libressl/lib" $LDFLAGS
set -gx CPPFLAGS "-I/usr/local/opt/libressl/include" $CPPFLAGS
set -g fish_user_paths "/usr/local/opt/libressl/bin" $fish_user_paths

But still C++20 concepts library makes build fail.

In file included from /Users/benjioh5/Coding/hobby/4_Contribution/ImHex/source/helpers/crypto.cpp:3:
/Users/benjioh5/Coding/hobby/4_Contribution/ImHex/include/providers/provider.hpp:6:10: fatal error:
      'concepts' file not found
#include <concepts>

@the-wondersmith
Copy link

@the-wondersmith I did same thing on my environment. openssl@1.1 or libressl works fine now.

this is my fish setting.

# apple llvm to homebrew llvm
set -gx LDFLAGS "-L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib"
set -gx CPPFLAGS "-I/usr/local/opt/llvm/include"
set -g fish_user_paths "/usr/local/opt/llvm/bin" $fish_user_paths

# add openssl@1.1
#set -gx LDFLAGS "-L/usr/local/opt/openssl@1.1/lib"
#set -gx CPPFLAGS "-I/usr/local/opt/openssl@1.1/include"
#set -gx PKG_CONFIG_PATH "/usr/local/opt/openssl@1.1/lib/pkgconfig"

# add libressl
set -gx LDFLAGS "-L/usr/local/opt/libressl/lib" $LDFLAGS
set -gx CPPFLAGS "-I/usr/local/opt/libressl/include" $CPPFLAGS
set -g fish_user_paths "/usr/local/opt/libressl/bin" $fish_user_paths

But still C++20 concepts library makes build fail.

In file included from /Users/benjioh5/Coding/hobby/4_Contribution/ImHex/source/helpers/crypto.cpp:3:
/Users/benjioh5/Coding/hobby/4_Contribution/ImHex/include/providers/provider.hpp:6:10: fatal error:
      'concepts' file not found
#include <concepts>

Yeah, I just tracked that down. Looking for a work around right now. This seems to be pretty informative, but I'm still making my way through it...

@benjioh5
Copy link
Author

benjioh5 commented Dec 6, 2020

@the-wondersmith how about using preprocessor on specific code? msgpack-c project works around this way.

msgpack/msgpack-c#658

replace line 49

#include "adaptor/cpp17/optional.hpp"
with this

// XCode 9.3 workaround
#if defined(__has_include) && __has_include()
#include "adaptor/cpp17/optional.hpp"
#endif // __has_include()

@the-wondersmith
Copy link

@the-wondersmith how about using preprocessor on specific code? msgpack-c project works around this way.

msgpack/msgpack-c#658

replace line 49
#include "adaptor/cpp17/optional.hpp"
with this
// XCode 9.3 workaround
#if defined(__has_include) && __has_include()
#include "adaptor/cpp17/optional.hpp"
#endif // __has_include()

I'm 100% game to test it if you tell me how / where to apply the fix. Full disclosure, I'm primarily a Python programmer. I can do C / C++ in a pinch if I have to, but it's very much not my programming "mother tongue" so to speak 😅

@dsxack
Copy link

dsxack commented Dec 6, 2020

I have fixed the problem with concepts in this way:

brew install gcc
cd ImHex/build
cmake .. -DCMAKE_C_COMPILER=/usr/local/bin/gcc-10 -DCMAKE_CXX_COMPILER=/usr/local/bin/g++-10

but I have a new problem:

/Users/dmitriysmotrov/space/dsxack/ImHex/source/lang/evaluator.cpp:187:59: error: no matching function for call to 'max(u64&, size_t&)'
  187 |                 unionSize = std::max(memberSize, unionSize);
      |                                                           ^

all log:

make
Scanning dependencies of target ImHex
[  2%] Building CXX object CMakeFiles/ImHex.dir/source/main.cpp.o
[  5%] Building CXX object CMakeFiles/ImHex.dir/source/window.cpp.o
[  8%] Building CXX object CMakeFiles/ImHex.dir/source/helpers/utils.cpp.o
[ 11%] Building CXX object CMakeFiles/ImHex.dir/source/helpers/crypto.cpp.o
[ 13%] Building CXX object CMakeFiles/ImHex.dir/source/helpers/patches.cpp.o
[ 16%] Building CXX object CMakeFiles/ImHex.dir/source/helpers/math_evaluator.cpp.o
[ 19%] Building CXX object CMakeFiles/ImHex.dir/source/helpers/project_file_handler.cpp.o
[ 22%] Building CXX object CMakeFiles/ImHex.dir/source/helpers/loader_script_handler.cpp.o
[ 25%] Building CXX object CMakeFiles/ImHex.dir/source/lang/preprocessor.cpp.o
[ 27%] Building CXX object CMakeFiles/ImHex.dir/source/lang/lexer.cpp.o
[ 30%] Building CXX object CMakeFiles/ImHex.dir/source/lang/parser.cpp.o
[ 33%] Building CXX object CMakeFiles/ImHex.dir/source/lang/validator.cpp.o
[ 36%] Building CXX object CMakeFiles/ImHex.dir/source/lang/evaluator.cpp.o
/Users/dmitriysmotrov/space/dsxack/ImHex/source/lang/evaluator.cpp: In member function 'std::pair<hex::lang::PatternData*, long unsigned int> hex::lang::Evaluator::createUnionPattern(hex::lang::ASTNodeVariableDecl*, u64)':
/Users/dmitriysmotrov/space/dsxack/ImHex/source/lang/evaluator.cpp:187:59: error: no matching function for call to 'max(u64&, size_t&)'
  187 |                 unionSize = std::max(memberSize, unionSize);
      |                                                           ^
In file included from /usr/local/Cellar/gcc/10.2.0/include/c++/10.2.0/bits/specfun.h:45,
                 from /usr/local/Cellar/gcc/10.2.0/include/c++/10.2.0/cmath:1927,
                 from /Users/dmitriysmotrov/space/dsxack/ImHex/include/providers/provider.hpp:5,
                 from /Users/dmitriysmotrov/space/dsxack/ImHex/include/lang/evaluator.hpp:5,
                 from /Users/dmitriysmotrov/space/dsxack/ImHex/source/lang/evaluator.cpp:1:
/usr/local/Cellar/gcc/10.2.0/include/c++/10.2.0/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/local/Cellar/gcc/10.2.0/include/c++/10.2.0/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
/Users/dmitriysmotrov/space/dsxack/ImHex/source/lang/evaluator.cpp:187:59: note:   deduced conflicting types for parameter 'const _Tp' ('long long unsigned int' and 'size_t' {aka 'long unsigned int'})
  187 |                 unionSize = std::max(memberSize, unionSize);
      |                                                           ^
In file included from /usr/local/Cellar/gcc/10.2.0/include/c++/10.2.0/bits/specfun.h:45,
                 from /usr/local/Cellar/gcc/10.2.0/include/c++/10.2.0/cmath:1927,
                 from /Users/dmitriysmotrov/space/dsxack/ImHex/include/providers/provider.hpp:5,
                 from /Users/dmitriysmotrov/space/dsxack/ImHex/include/lang/evaluator.hpp:5,
                 from /Users/dmitriysmotrov/space/dsxack/ImHex/source/lang/evaluator.cpp:1:
/usr/local/Cellar/gcc/10.2.0/include/c++/10.2.0/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/local/Cellar/gcc/10.2.0/include/c++/10.2.0/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
/Users/dmitriysmotrov/space/dsxack/ImHex/source/lang/evaluator.cpp:187:59: note:   deduced conflicting types for parameter 'const _Tp' ('long long unsigned int' and 'size_t' {aka 'long unsigned int'})
  187 |                 unionSize = std::max(memberSize, unionSize);
      |                                                           ^
In file included from /usr/local/Cellar/gcc/10.2.0/include/c++/10.2.0/string:52,
                 from /Users/dmitriysmotrov/space/dsxack/ImHex/include/providers/provider.hpp:9,
                 from /Users/dmitriysmotrov/space/dsxack/ImHex/include/lang/evaluator.hpp:5,
                 from /Users/dmitriysmotrov/space/dsxack/ImHex/source/lang/evaluator.cpp:1:
/usr/local/Cellar/gcc/10.2.0/include/c++/10.2.0/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/local/Cellar/gcc/10.2.0/include/c++/10.2.0/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
/Users/dmitriysmotrov/space/dsxack/ImHex/source/lang/evaluator.cpp:187:59: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long unsigned int'
  187 |                 unionSize = std::max(memberSize, unionSize);
      |                                                           ^
In file included from /usr/local/Cellar/gcc/10.2.0/include/c++/10.2.0/string:52,
                 from /Users/dmitriysmotrov/space/dsxack/ImHex/include/providers/provider.hpp:9,
                 from /Users/dmitriysmotrov/space/dsxack/ImHex/include/lang/evaluator.hpp:5,
                 from /Users/dmitriysmotrov/space/dsxack/ImHex/source/lang/evaluator.cpp:1:
/usr/local/Cellar/gcc/10.2.0/include/c++/10.2.0/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/local/Cellar/gcc/10.2.0/include/c++/10.2.0/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
/Users/dmitriysmotrov/space/dsxack/ImHex/source/lang/evaluator.cpp:187:59: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long unsigned int'
  187 |                 unionSize = std::max(memberSize, unionSize);
      |                                                           ^
make[2]: *** [CMakeFiles/ImHex.dir/source/lang/evaluator.cpp.o] Error 1
make[1]: *** [CMakeFiles/ImHex.dir/all] Error 2
make: *** [all] Error 2

@the-wondersmith
Copy link

@dsxack I've reached the same point of progress you did, though I had to fiddle with the flags passed to cmake.

It seems like we're pretty close. Any idea of how to get the build to complete?

@WerWolv
Copy link
Owner

WerWolv commented Dec 7, 2020

@dsxack Oh that's one place I forgot. You can fix it by explicitly casting unionSize to and u64. I'll fix that soon.

@the-wondersmith
Copy link

the-wondersmith commented Dec 7, 2020

@dsxack Oh that's one place I forgot. You can fix it by explicitly casting unionSize to and u64. I'll fix that soon.

That did it. Got a new error though...

MacBook-Pro:build user$ make -j
Scanning dependencies of target ImHex
[  2%] Building CXX object CMakeFiles/ImHex.dir/source/lang/evaluator.cpp.o
[  5%] Linking CXX executable ImHex
ld: library not found for -lglfw
collect2: error: ld returned 1 exit status
make[2]: *** [ImHex] Error 1
make[1]: *** [CMakeFiles/ImHex.dir/all] Error 2
make: *** [all] Error 2

@WerWolv
Copy link
Owner

WerWolv commented Dec 7, 2020

Looks like you just don't have the right libraries installed now. You need glfw for starters. And a bunch of other ones that are mentioned in the readme

@the-wondersmith
Copy link

the-wondersmith commented Dec 7, 2020

Looks like you just don't have the right libraries installed now. You need glfw for starters. And a bunch of other ones that are mentioned in the readme

It looks that way, but that's not the case. I'm sure it's probably just a local configuration thing, but I fixed it by explicitly providing the requisite paths thusly -

cmake .. -DCMAKE_C_COMPILER=/usr/local/bin/gcc-10 -DCMAKE_CXX_COMPILER=/usr/local/bin/g++-10 -DCMAKE_C_FLAGS="-I/usr/local/Cellar/openssl@1.1/1.1.1h/include -I/usr/local/Cellar/llvm/11.0.0/include" -DCMAKE_CXX_FLAGS="-I/usr/local/Cellar/openssl@1.1/1.1.1h/include -I/usr/local/Cellar/llvm/11.0.0/include" -DCMAKE_EXE_LINKER_FLAGS="-L/usr/local/opt/openssl/lib -L/usr/local/Cellar/glfw/3.3.2/lib -L/usr/local/opt/llvm/lib -L/usr/local/Cellar/libmagic/5.39/lib -L/usr/local/Cellar/capstone/4.0.2/lib -Wl,-rpath,/usr/local/opt/llvm/lib"

Everything builds now, but I'm hitting a linking error -

[100%] Linking CXX executable ImHex
Undefined symbols for architecture x86_64:
  "__ZN4llvm8demangleERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", referenced from:
      __ZN3hex9ViewTools13drawDemanglerEv in view_tools.cpp.o
      __ZN3hex11ViewStrings23createStringContextMenuERKNS_11FoundStringE in view_strings.cpp.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make[2]: *** [ImHex] Error 1
make[1]: *** [CMakeFiles/ImHex.dir/all] Error 2
make: *** [all] Error 2

I've updated the gist I made with the full output, if that's helpful

@WerWolv
Copy link
Owner

WerWolv commented Dec 7, 2020

It can't find llvm::demangle now. Make sure you have up-to-date llvm-libs installed. That function can be found in libLLVMDemangle, possible requiring v11.0.0 since that's the one I'm using

@dsxack
Copy link

dsxack commented Dec 7, 2020

@dsxack Oh that's one place I forgot. You can fix it by explicitly casting unionSize to and u64. I'll fix that soon.

@WerWolv thank you, I did that, but have a new problem:

make
[  2%] Building CXX object CMakeFiles/ImHex.dir/source/views/view_hexeditor.cpp.o
/Users/dmitriysmotrov/space/dsxack/ImHex/source/views/view_hexeditor.cpp: In member function 'bool hex::ViewHexEditor::loadFromFile(std::string, std::vector<unsigned char>&)':
/Users/dmitriysmotrov/space/dsxack/ImHex/source/views/view_hexeditor.cpp:496:23: error: 'ftello64' was not declared in this scope; did you mean 'ftello'?
  496 |         size_t size = ftello64(file);
      |                       ^~~~~~~~
      |                       ftello
make[2]: *** [CMakeFiles/ImHex.dir/source/views/view_hexeditor.cpp.o] Error 1
make[1]: *** [CMakeFiles/ImHex.dir/all] Error 2
make: *** [all] Error 2

I did use ftello instead ftello64 and this goes further but I have the same problem with lglfw:

ld: library not found for -lglfw

I go to fix it now, I think it is my local problem

@dsxack
Copy link

dsxack commented Dec 7, 2020

Now I have the same problem which have @the-wondersmith

gcc that installed by HomeBrew:

make
[  2%] Linking CXX executable ImHex
ld: warning: dylib (/usr/local/Cellar/glfw/3.3.2/lib/libglfw.dylib) was built for newer macOS version (11.0) than being linked (10.16)
ld: warning: dylib (/usr/local/Cellar/openssl@1.1/1.1.1h/lib/libcrypto.dylib) was built for newer macOS version (11.0) than being linked (10.16)
ld: warning: dylib (/usr/local/Cellar/capstone/4.0.2/lib/libcapstone.dylib) was built for newer macOS version (11.0) than being linked (10.16)
ld: warning: dylib (/usr/local/Cellar/python@3.8/3.8.6_2/Frameworks/Python.framework/Versions/3.8/lib/libpython3.8.dylib) was built for newer macOS version (11.0) than being linked (10.16)
ld: warning: dylib (/usr/local/opt/llvm/lib/libunwind.dylib) was built for newer macOS version (11.0) than being linked (10.16)
ld: warning: dylib (/usr/local/opt/llvm/lib/libunwind.dylib) was built for newer macOS version (11.0) than being linked (10.16)
Undefined symbols for architecture x86_64:
  "__ZN4llvm8demangleERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", referenced from:
      __ZN3hex9ViewTools13drawDemanglerEv in view_tools.cpp.o
      __ZN3hex11ViewStrings23createStringContextMenuERKNS_11FoundStringE in view_strings.cpp.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make[2]: *** [ImHex] Error 1
make[1]: *** [CMakeFiles/ImHex.dir/all] Error 2
make: *** [all] Error 2

gcc that installed by MacPorts:

make
[  2%] Linking CXX executable ImHex
Undefined symbols for architecture x86_64:
  "__ZN4llvm8demangleERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", referenced from:
      __ZN3hex9ViewTools13drawDemanglerEv in view_tools.cpp.o
      __ZN3hex11ViewStrings23createStringContextMenuERKNS_11FoundStringE in view_strings.cpp.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make[2]: *** [ImHex] Error 1
make[1]: *** [CMakeFiles/ImHex.dir/all] Error 2
make: *** [all] Error 2

Now I try to fix that with advice that @WerWolv given: updating llvm-libs

@the-wondersmith
Copy link

@WerWolv @dsxack This seems relevant, but I'm not familiar enough with the actual source (or C++ for that matter) to tell if it actually is or how to implement the applicable fix if it is.

@WerWolv
Copy link
Owner

WerWolv commented Dec 7, 2020

Yeah, it's simply a linker error caused by the linker not finding the implementation of a function that was used in ImHex. That function in this case is std::string llvm::demangle(std::string), most likely caused by them not having the right version of llvm installed. It can find libLLVMDemangle but not that function.

@the-wondersmith
Copy link

@WerWolv @dsxack It looks like (from reading over this) some kind of oversight or omission in the llvm package from Homebrew, at least as compared to options that were apparently previously available for the Homebrew llvm package. I'm going to try compiling and installing llvm11 from source and see if that fixes it.

@the-wondersmith
Copy link

@WerWolv I've tried compiling ImHex using four different versions of LLVM, every single one throws an error of one kind or another. The only way I've been able to get a successful build is by using GCC 10, which will successfully build ImHex and then lead to a linking failure.

I've narrowed the actual issue down to the symbol __cxx1112basic_stringIcSt11char_traitsIcESaIcEEE, which is apparently part of the CXX11 ABI. This is apparently a common enough issue encountered when trying to cross-compile Python extensions for multiple OS's (discussion of which are where I found the descriptions and solutions to the issue). The most helpful-seeming thing I found was this explanation of what's causing the issue - a difference in the way that GCC and clang handle namespace changes.

As near as I can tell, there are two options - either apply the fix / patch detailed in the link so that GCC can be used to compile or figure a way to use just LLVM. I'd imagine that the ideal solution would be to get ImHex to compile exclusively with LLVM / clang, and if I'm understanding correctly that's just a matter of forcing LLVM to use the C++20 standard instead of the default of... not that. I haven't been able to get cmake or llvm to actually do that, so I'm at a bit of an impasse.

Hopefully what I've turned up is useful enough that someone else can get us over the finish line with it.

@vainPointer
Copy link

vainPointer commented Dec 9, 2020

@the-wondersmith Thanks for the link you provide, I tried following:

> echo __ZN4llvm8demangleERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE | c++filt
llvm::demangle(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
> nm /usr/local/opt/llvm/lib/libLLVM.dylib | grep -e "llvm.demangle"
0000000000002a80 T __ZN4llvm8demangleERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE
> echo __ZN4llvm8demangleERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE | c++filt
llvm::demangle(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)

I guess build LLVM using g++-10 may get this problem fixed. Or we can let g++-10 compile the symbols in the clang style. Another clever way may exist is to translate the g++-10 style symbols (std::__cxx11) to clang style symbols (std::__1) in the ImHex object files.

@nmantani
Copy link
Contributor

FreeBSD also has the same issue of undefined symbol error with libLLVMDemangle.a because FreeBSD LLVM packages are built with Clang and ImHex needs GCC 10 to build it.

@the-wondersmith
Copy link

@nmantani I saw your posting about the patches you made to the codebase to get ImHex to compile on FreeBSD. That's awesome, by the way.

Do you have any idea if the same (or possibly similar) patches will solve the issues we've been experiencing on MacOS ?

@the-wondersmith
Copy link

the-wondersmith commented Dec 12, 2020

@WerWolv @nmantani My curiosity got the better of me. Turns out, the answer is "sort of" I pulled the absolute latest revision, then applied your patches. I had to manually fiddle with the patches to CMakeLists.txt, but it all seemed fine. I issued the configuration command as:

cmake -DCMAKE_C_COMPILER=$CCGCC -DCMAKE_CXX_COMPILER=$CPPGCC \
-DCMAKE_C_FLAGS="-I/usr/local/Cellar/openssl@1.1/1.1.1h/include -I/usr/local/llvm11/include -I/usr/local/Cellar/freetype/2.10.4/include -I/usr/local/Cellar/freetype/2.10.4/include/freetype2" \
-DCMAKE_CXX_FLAGS="-std=c++14 -std=c++17 -std=gnu++2a -I/usr/local/Cellar/openssl@1.1/1.1.1h/include -I/usr/local/Cellar/freetype/2.10.4/include -I/usr/local/Cellar/freetype/2.10.4/include/freetype2" \
-DCMAKE_EXE_LINKER_FLAGS="-L/usr/local/opt/openssl/lib -L/usr/local/Cellar/glfw/3.3.2/lib -L/usr/local/Cellar/libmagic/5.39/lib -L/usr/local/Cellar/capstone/4.0.2/lib -L/usr/local/opt/llvm/lib -L/usr/local/Cellar/freetype/2.10.4/lib -Wl,-rpath,/usr/local/opt/llvm/lib" ..

Which got ImHex to compile just fine (same as before), but now the missing symbols are different:

[ 97%] Building CXX object CMakeFiles/imhex.dir/libs/ImGui/source/TextEditor.cpp.o
[100%] Linking CXX executable imhex
Undefined symbols for architecture x86_64:
  "_FT_Add_Default_Modules", referenced from:
      __ZN13ImGuiFreeType14BuildFontAtlasEP11ImFontAtlasj in imgui_freetype.cpp.o
  "_FT_Done_Face", referenced from:
      __ZN12_GLOBAL__N_112FreeTypeFont9CloseFontEv in imgui_freetype.cpp.o
  "_FT_Done_Library", referenced from:
      __ZN13ImGuiFreeType14BuildFontAtlasEP11ImFontAtlasj in imgui_freetype.cpp.o
  "_FT_Get_Char_Index", referenced from:
      __ZN12_GLOBAL__N_112FreeTypeFont9LoadGlyphEj in imgui_freetype.cpp.o
      __Z28ImFontAtlasBuildWithFreeTypeP14FT_LibraryRec_P11ImFontAtlasj in imgui_freetype.cpp.o
  "_FT_GlyphSlot_Embolden", referenced from:
      __ZN12_GLOBAL__N_112FreeTypeFont9LoadGlyphEj in imgui_freetype.cpp.o
  "_FT_GlyphSlot_Oblique", referenced from:
      __ZN12_GLOBAL__N_112FreeTypeFont9LoadGlyphEj in imgui_freetype.cpp.o
  "_FT_Load_Glyph", referenced from:
      __ZN12_GLOBAL__N_112FreeTypeFont9LoadGlyphEj in imgui_freetype.cpp.o
  "_FT_New_Library", referenced from:
      __ZN13ImGuiFreeType14BuildFontAtlasEP11ImFontAtlasj in imgui_freetype.cpp.o
  "_FT_New_Memory_Face", referenced from:
      __ZN12_GLOBAL__N_112FreeTypeFont8InitFontEP14FT_LibraryRec_RK12ImFontConfigj in imgui_freetype.cpp.o
  "_FT_Render_Glyph", referenced from:
      __ZN12_GLOBAL__N_112FreeTypeFont21RenderGlyphAndGetInfoEPNS_9GlyphInfoE in imgui_freetype.cpp.o
  "_FT_Request_Size", referenced from:
      __ZN12_GLOBAL__N_112FreeTypeFont14SetPixelHeightEi in imgui_freetype.cpp.o
  "_FT_Select_Charmap", referenced from:
      __ZN12_GLOBAL__N_112FreeTypeFont8InitFontEP14FT_LibraryRec_RK12ImFontConfigj in imgui_freetype.cpp.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make[2]: *** [imhex] Error 1
make[1]: *** [CMakeFiles/imhex.dir/all] Error 2
make: *** [all] Error 2

Thoughts?

@nmantani
Copy link
Contributor

@the-wondersmith Though I did not see this error on FreeBSD, it seems that the missing symbols are FreeType functions. Adding find_package(Freetype REQUIRED) line and adding ${FREETYPE_LIBRARIES} to target_link_libraries() in CMakeLists.txt fix the error?

This Q&A has an example of CMakeLists.txt.
https://stackoverflow.com/questions/23888274/linking-freetype-with-cmake

@the-wondersmith
Copy link

the-wondersmith commented Dec 14, 2020

@WerWolv After looking over @nmantani's comment and making the suggested tweak, ImHex does indeed build as expected on MacOS. As per #93, the app does look a little weird on Retina displays, but I'm working a fix for that too.

I've uploaded the patches as well as a script to apply them for anyone that would like them here.

@marysaka marysaka self-assigned this Dec 18, 2020
@filcab
Copy link

filcab commented Dec 18, 2020

ok, so... we have the GUI issue on mac (plenty of people have their own patches, and I pushed PR #92 already (can build with latest clang and gcc10, at least), so won't be talking about compiling ImHex here).

Here's something I posted on the free type PR (low audience because it was after it was closed), and is relevant for this:

I've tried that, but it didn't work too well.
Changing font scale "works" but the UI is still drawn as if the font is large. I can, though, hack it like this:

diff --git a/source/window.cpp b/source/window.cpp
index f30f1ee..ed99407 100644
--- a/source/window.cpp
+++ b/source/window.cpp
@@ -223,7 +223,8 @@ namespace hex {
             glfwGetMonitorContentScale(monitor, &xscale, &yscale);
 
             // In case the horizontal and vertical scale are different, fall b
ack on the average
-            this->m_globalScale = this->m_fontScale = std::midpoint(xscale, ys
cale);
+            //this->m_globalScale = this->m_fontScale = std::midpoint(xscale, 
yscale);
+            this->m_globalScale = 1.0;

This is... obviously wrong. But I'm not familiar with the codebase, maybe someone else can figure out what the correct fix is with this info.

Thank you,
Filipe

io.DisplayFramebufferScale is 2 on both dimensions
The window has these properties when running: w: 1440, h: 855, display_w: 2880, display_h: 1710

The patch above works, but is probably not ideal?
Though it does seem like we're scaling more than once, so setting one of the scales to 1 might help.

@marysaka
Copy link
Contributor

As of 310059f, build on macOS is officially supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants