-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Comments
@benjioh5 I personally plan to look into supporting clang when it could be done ^^ |
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 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? |
Okay, look like it's all on Apple / clang now. All those errors are just |
@the-wondersmith I did same thing on my environment. openssl@1.1 or libressl works fine now. this is my fish setting.
But still C++20 concepts library makes build fail.
|
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... |
@the-wondersmith how about using preprocessor on specific code? msgpack-c project works around this way.
|
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 😅 |
I have fixed the problem with 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:
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 |
@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? |
@dsxack Oh that's one place I forgot. You can fix it by explicitly casting |
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 |
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 |
It can't find |
@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
I go to fix it now, I think it is my local problem |
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 |
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 |
@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. |
@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 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. |
@the-wondersmith Thanks for the link you provide, I tried following:
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 ( |
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. |
@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 ? |
@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 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? |
@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. |
@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. |
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:
The patch above works, but is probably not ideal? |
As of 310059f, build on macOS is officially supported. |
Is there any plan to support mac os?
I've tried some build and got this.
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?
The text was updated successfully, but these errors were encountered: