jmpews / Dobby

a lightweight, multi-platform, multi-architecture hook framework.
Apache License 2.0
3.88k stars 794 forks source link

Fix issues when building with gcc on linux #220

Open wangyinz opened 1 year ago

wangyinz commented 1 year ago

I was trying to build Dobby with gcc on a linux system and ran into multiple issues.

The first issue is due to the use of __has_feature, which is only defined in llvm, and gcc will throw an error when preprocessing that keyword. I got it fixed by defining it to 0 when no defined by the compiler, which is in commit https://github.com/jmpews/Dobby/commit/582a3e91b21a21487f3a28f7837e596111e3fbe4.

Then, there are two libraries defined for Darwin only but got accidentally built without checking the platform. This is fixed by adding a if statement to the CMake definition, which is in commit https://github.com/jmpews/Dobby/commit/5e9770db6333dc78e535ad23c082e927e2edd6be.

The example got a dependency on pthread, but it is not linked by cmake by default (at least not with gcc). I added a dependency in https://github.com/jmpews/Dobby/commit/fe2bf6d6a5d06a3f7b21ec6fb471321179409ddd.

While fixing these, I also noticed the issue reported in https://github.com/jmpews/Dobby/issues/217. This is due to how logging is enabled here: https://github.com/jmpews/Dobby/blob/6f065cfcce47e5aa43901910eb702884f3cf4777/external/logging/logging/logging.h#L147-L158 The LOG_FUNCTION_IMPL will only be overidden when LOGGING_DISABLE is defined. But it isn't even when DOBBY_DEBUG is set to OFF. This is fixed by the else branch in https://github.com/jmpews/Dobby/commit/e8de5638cef26a2b677e0207656a221df206f9d4