pok3r-custom / pok3r_re_firmware

Reverse engineering project for the POK3R and related keyboards.
219 stars 17 forks source link

Error building pok3rtool on MacOS 10.13.6 High Sierra #24

Closed rex closed 5 years ago

rex commented 5 years ago

I was excited to find this repository but I've been unable to build the software so far. Please help! I'll include as much information as possible below.

screenshot 2018-08-10 10 57 40

I use homebrew to manage software like cmake and make, and I have the coreutils library installed as well.

cmake version 3.12.0

CMake suite maintained and supported by Kitware (kitware.com/cmake).

~/Code/OSS/pok3rtool master*
λ make --version
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i386-apple-darwin11.3.0
Here is the entire output from the console, from the initial clone through to the failed build ``` λ git clone --recurse-submodules git@github.com:pok3r-custom/pok3rtool.git Cloning into 'pok3rtool'... warning: templates not found in /Users/pierce.moore/.git-templates remote: Counting objects: 895, done. remote: Compressing objects: 100% (36/36), done. remote: Total 895 (delta 22), reused 31 (delta 12), pack-reused 847 Receiving objects: 100% (895/895), 297.61 KiB | 2.40 MiB/s, done. Resolving deltas: 100% (643/643), done. Submodule 'libchaos' (https://gitlab.com/ChaoticEnigma/libchaos.git) registered for path 'libchaos' Submodule 'nlohmann_json' (https://github.com/nlohmann/json) registered for path 'nlohmann_json' Cloning into '/Users/pierce.moore/Code/OSS/pok3rtool/libchaos'... warning: templates not found in /Users/pierce.moore/.git-templates remote: Enumerating objects: 8234, done. remote: Counting objects: 100% (8234/8234), done. remote: Compressing objects: 100% (2016/2016), done. remote: Total 8234 (delta 6222), reused 8177 (delta 6200) Receiving objects: 100% (8234/8234), 4.32 MiB | 6.03 MiB/s, done. Resolving deltas: 100% (6222/6222), done. Cloning into '/Users/pierce.moore/Code/OSS/pok3rtool/nlohmann_json'... warning: templates not found in /Users/pierce.moore/.git-templates remote: Counting objects: 41071, done. remote: Total 41071 (delta 0), reused 0 (delta 0), pack-reused 41070 Receiving objects: 100% (41071/41071), 157.45 MiB | 2.05 MiB/s, done. Resolving deltas: 100% (33569/33569), done. Submodule path 'libchaos': checked out '1a91021d402beffc8d0f62f6bcafe8e2604410e5' Submodule path 'nlohmann_json': checked out '7fa4ddf93e4fc51bd6af78a9666e721e3a159828' ~/Code/OSS 1m 22s λ cd pok3rtool ~/Code/OSS/pok3rtool master λ cmake . -- The C compiler identification is AppleClang 9.1.0.9020039 -- The CXX compiler identification is AppleClang 9.1.0.9020039 -- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- LibChaos: Other (Static) - Core,JPEG,WebP - remotes/origin/patches/pok3r-0-g1a91021 -- Using the multi-header code from /Users/pierce.moore/Code/OSS/pok3rtool/nlohmann_json/include/ -- Configuring done WARNING: Target "chaos-shared" has EXCLUDE_FROM_ALL set and will not be built by default but an install rule has been provided for it. CMake does not define behavior for this case. WARNING: Target "chaos-shared" has EXCLUDE_FROM_ALL set and will not be built by default but an install rule has been provided for it. CMake does not define behavior for this case. -- Generating done -- Build files have been written to: /Users/pierce.moore/Code/OSS/pok3rtool ~/Code/OSS/pok3rtool master* λ make Scanning dependencies of target chaos-shared [ 0%] Building CXX object libchaos/chaos/CMakeFiles/chaos-shared.dir/chaos.cpp.o [ 1%] Building CXX object libchaos/chaos/CMakeFiles/chaos-shared.dir/base/zclock.cpp.o [ 2%] Building CXX object libchaos/chaos/CMakeFiles/chaos-shared.dir/base/zerror.cpp.o [ 3%] Building CXX object libchaos/chaos/CMakeFiles/chaos-shared.dir/base/zexception.cpp.o [ 5%] Building CXX object libchaos/chaos/CMakeFiles/chaos-shared.dir/base/zlog.cpp.o [ 6%] Building CXX object libchaos/chaos/CMakeFiles/chaos-shared.dir/base/zlogworker.cpp.o [ 6%] Building CXX object libchaos/chaos/CMakeFiles/chaos-shared.dir/base/ztime.cpp.o [ 7%] Building CXX object libchaos/chaos/CMakeFiles/chaos-shared.dir/data/zbinary.cpp.o [ 8%] Building CXX object libchaos/chaos/CMakeFiles/chaos-shared.dir/data/ztable.cpp.o [ 10%] Building CXX object libchaos/chaos/CMakeFiles/chaos-shared.dir/file/zfile.cpp.o [ 11%] Building CXX object libchaos/chaos/CMakeFiles/chaos-shared.dir/file/zimage.cpp.o [ 12%] Building CXX object libchaos/chaos/CMakeFiles/chaos-shared.dir/file/zpdf.cpp.o [ 13%] Building CXX object libchaos/chaos/CMakeFiles/chaos-shared.dir/file/image/zbmp.cpp.o [ 13%] Building CXX object libchaos/chaos/CMakeFiles/chaos-shared.dir/file/image/zppm.cpp.o [ 15%] Building C object libchaos/chaos/CMakeFiles/chaos-shared.dir/lib/xxhash.c.o [ 16%] Building CXX object libchaos/chaos/CMakeFiles/chaos-shared.dir/math/zexpression.cpp.o [ 17%] Building CXX object libchaos/chaos/CMakeFiles/chaos-shared.dir/math/zformula.cpp.o [ 18%] Building CXX object libchaos/chaos/CMakeFiles/chaos-shared.dir/math/znumber.cpp.o [ 20%] Building CXX object libchaos/chaos/CMakeFiles/chaos-shared.dir/math/zmath.cpp.o [ 21%] Building CXX object libchaos/chaos/CMakeFiles/chaos-shared.dir/misc/zencrypt.cpp.o [ 21%] Building CXX object libchaos/chaos/CMakeFiles/chaos-shared.dir/misc/zhash.cpp.o [ 22%] Building CXX object libchaos/chaos/CMakeFiles/chaos-shared.dir/misc/zoptions.cpp.o [ 24%] Building CXX object libchaos/chaos/CMakeFiles/chaos-shared.dir/misc/zrandom.cpp.o [ 25%] Building CXX object libchaos/chaos/CMakeFiles/chaos-shared.dir/misc/zuid.cpp.o [ 26%] Building CXX object libchaos/chaos/CMakeFiles/chaos-shared.dir/net/zaddress.cpp.o [ 27%] Building CXX object libchaos/chaos/CMakeFiles/chaos-shared.dir/net/zconnection.cpp.o [ 29%] Building CXX object libchaos/chaos/CMakeFiles/chaos-shared.dir/net/zdatagramsocket.cpp.o [ 29%] Building CXX object libchaos/chaos/CMakeFiles/chaos-shared.dir/net/zsocket.cpp.o [ 30%] Building CXX object libchaos/chaos/CMakeFiles/chaos-shared.dir/net/zstreamsocket.cpp.o [ 31%] Building CXX object libchaos/chaos/CMakeFiles/chaos-shared.dir/string/zjson.cpp.o [ 32%] Building CXX object libchaos/chaos/CMakeFiles/chaos-shared.dir/string/zpath.cpp.o [ 34%] Building CXX object libchaos/chaos/CMakeFiles/chaos-shared.dir/string/zstring.cpp.o [ 35%] Building CXX object libchaos/chaos/CMakeFiles/chaos-shared.dir/string/zstring-unicode.cpp.o [ 36%] Building CXX object libchaos/chaos/CMakeFiles/chaos-shared.dir/string/zxml.cpp.o [ 36%] Building CXX object libchaos/chaos/CMakeFiles/chaos-shared.dir/thread/zcondition.cpp.o [ 37%] Building CXX object libchaos/chaos/CMakeFiles/chaos-shared.dir/thread/zmutex.cpp.o [ 39%] Building CXX object libchaos/chaos/CMakeFiles/chaos-shared.dir/thread/zthread.cpp.o [ 40%] Building CXX object libchaos/chaos/CMakeFiles/chaos-shared.dir/file/image/zjpeg.cpp.o /Users/pierce.moore/Code/OSS/pok3rtool/libchaos/chaos/file/image/zjpeg.cpp:49:39: warning: cast from 'const unsigned char *' to 'unsigned char *' drops const qualifier [-Wcast-qual] jpeg_mem_src(&cinfo, (zbyte *)data.raw(), data.size()); ^ 1 warning generated. [ 41%] Building CXX object libchaos/chaos/CMakeFiles/chaos-shared.dir/file/image/zwebp.cpp.o [ 43%] Linking CXX shared library libchaos.dylib Undefined symbols for architecture x86_64: "LibChaos::ZHashBigBase::md5_finish(void*)", referenced from: LibChaos::ZHashMethod<(LibChaos::ZHashBase::hashMethod)5>::~ZHashMethod() in zuid.cpp.o LibChaos::ZHashMethod<(LibChaos::ZHashBase::hashMethod)5>::finishHash() in zuid.cpp.o "LibChaos::ZHashBigBase::sha1_finish(void*)", referenced from: LibChaos::ZHashMethod<(LibChaos::ZHashBase::hashMethod)6>::~ZHashMethod() in zuid.cpp.o LibChaos::ZHashMethod<(LibChaos::ZHashBase::hashMethod)6>::finishHash() in zuid.cpp.o "LibChaos::ZHashBigBase::md5_feed(void*, unsigned char const*, unsigned long long)", referenced from: LibChaos::ZHashMethod<(LibChaos::ZHashBase::hashMethod)5>::feedHash(unsigned char const*, unsigned long long) in zuid.cpp.o "LibChaos::ZHashBigBase::md5_hash(unsigned char const*, unsigned long long)", referenced from: LibChaos::ZHashMethod<(LibChaos::ZHashBase::hashMethod)5>::ZHashMethod(unsigned char const*, unsigned long long) in zuid.cpp.o "LibChaos::ZHashBigBase::sha1_feed(void*, unsigned char const*, unsigned long long)", referenced from: LibChaos::ZHashMethod<(LibChaos::ZHashBase::hashMethod)6>::feedHash(unsigned char const*, unsigned long long) in zuid.cpp.o "LibChaos::ZHashBigBase::sha1_hash(unsigned char const*, unsigned long long)", referenced from: LibChaos::ZHashMethod<(LibChaos::ZHashBase::hashMethod)6>::ZHashMethod(unsigned char const*, unsigned long long) in zuid.cpp.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make[2]: *** [libchaos/chaos/libchaos.dylib] Error 1 make[1]: *** [libchaos/chaos/CMakeFiles/chaos-shared.dir/all] Error 2 make: *** [all] Error 2 ```

I'll try using the built-in make and update with the result.

Update: The result was the same.

~/Code/OSS/pok3rtool master*
λ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 9.1.0 (clang-902.0.39.2)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

~/Code/OSS/pok3rtool master*
λ g++ --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 9.1.0 (clang-902.0.39.2)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

The error that seems to be reoccurring is ld: symbol(s) not found for architecture x86_64. I will google around to see what I can come up with but I am out of my depth in a major way when it comes to resolving compiling/linking issues.

ChaoticEnigma commented 5 years ago

Ok, so I think there are two issues here. One is a typo on my part, there are some #ifdef where there should be #if. I will fix that later, because it won't ultimately solve your issue.

You need the OpenSSL library installed. I believe brew install openssl will do what you need. In theory, the CMake would produce an error first, but i guess that didn't happen here. I will also work on that.

Sorry for taking so long to get back on this, I've been very busy lately. Hopefully I can get back into this soon.

rex commented 5 years ago

@ChaoticConundrum No need at all for apologies, I'm just excited and appreciative this project hasn't been abandoned! I can confirm I have openssl installed:

λ brew list | grep openssl
openssl
openssl@1.1

I wish I could help debug/resolve this from the code side but I have absolutely no idea about C or C++. Are there any additional debug steps you'd like me to take?

This has got me suspicious about my own OpenSSL configuration. On a hunch I checked my openssl version for more information:

λ which openssl
/usr/bin/openssl

λ openssl version
LibreSSL 2.2.7

So I'm not actually using the homebrew openssl, I'm using the system openssl which AFAIK has been deprecated. Additionally, the brew version of openssl has additional information for specifying compile-time libraries:

For compilers to find this software you may need to set:
    LDFLAGS:  -L/usr/local/opt/openssl/lib
    CPPFLAGS: -I/usr/local/opt/openssl/include

I will try updating my $PATH to use the homebrew version of openssl and also add the flags entries as specified above and try it again.

rex commented 5 years ago

OMG. I am so excited. I got it to build! I did what I should have done in the first place and looked for other issues. I found your comment here and that's what cracked this cookie wide open. Here are the steps I took:

  1. Added openssl bin to the front of $PATH:
    • echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.zshrc
  2. Reloaded shell
  3. Cleaned the current directory
    • make clean
  4. Reran cmake but this time with CMAKE_PREFIX_PATH prepended
    • CMAKE_PREFIX_PATH=/usr/local/opt/openssl cmake .
  5. Reran make
    • make

It literally worked on the first try!!! You are awesome! Thank you so much for maintaining this awesome project!

λ ./pok3rtool list
List Devices...
Vortex POK3R RGB2: V1.01.00

Edit: One last question: is there a forum for people who have used this tool to flash their keyboards (RGB especially)? I have read through all the documentation you've provided here and the issues and frankly I'm terrified to actually attempt to flash the keyboard because I have no access to a hardware debugger in case it gets bricked. This might not be the best place to ask that info but any guidance you can provide would be appreciated :)

Final Edit: It seems like my keyboard might not even be supported. Is this an expected result?

λ pok3rtool list
List Devices...
Vortex POK3R RGB2: V1.01.00

λ pok3rtool version
Unknown device!
No device found, check connection and permissions
dontworryboutit commented 4 years ago

@rex I was getting the same issue. After looking through the code This worked for me:

./pok3rtool -t pok3r-rgb2 version
rex commented 4 years ago

Well whaddya know?

λ ./pok3rtool -t pok3r-rgb2 version
Opened Vortex POK3R RGB2
Version: V1.01.00

Thanks @dontworryboutit! I'm still not sure I'm confident enough about this to actually try and flash it, since it seems very likely it would brick the keyboard, but it's good to know it actually talks to the keyboard!