stevemk14ebr / PolyHook_2_0

C++20, x86/x64 Hooking Libary v2.0
MIT License
1.58k stars 222 forks source link

Cannot compile polyhook on linux using cmake #164

Closed fligger closed 1 year ago

fligger commented 1 year ago

Hey when trying to compile the polyhook project using cmake as descriped here I get the following error:

[user@fedora project]$ cmake --build "./_build/polyhook" --config Release --target INSTALL
gmake: *** No rule to make target 'INSTALL'.  Stop.

Am I doing anything incorrectly?

Full log:

[user@fedora depends]$ git clone --recursive https://github.com/stevemk14ebr/PolyHook_2_0.git
Cloning into 'PolyHook_2_0'...
remote: Enumerating objects: 4092, done.
remote: Counting objects: 100% (517/517), done.
remote: Compressing objects: 100% (260/260), done.
remote: Total 4092 (delta 314), reused 424 (delta 251), pack-reused 3575
Receiving objects: 100% (4092/4092), 1.94 MiB | 2.17 MiB/s, done.
Resolving deltas: 100% (2681/2681), done.
Submodule 'asmjit' (https://github.com/asmjit/asmjit.git) registered for path 'asmjit'
Submodule 'asmtk' (https://github.com/asmjit/asmtk.git) registered for path 'asmtk'
Submodule 'zydis' (https://github.com/zyantific/zydis.git) registered for path 'zydis'
Cloning into '/home/user/Documents/Source/c++/project/depends/PolyHook_2_0/asmjit'...
remote: Enumerating objects: 5499, done.        
remote: Counting objects: 100% (107/107), done.        
remote: Compressing objects: 100% (65/65), done.        
remote: Total 5499 (delta 42), reused 101 (delta 42), pack-reused 5392        
Receiving objects: 100% (5499/5499), 7.51 MiB | 13.51 MiB/s, done.
Resolving deltas: 100% (3826/3826), done.
Cloning into '/home/user/Documents/Source/c++/project/depends/PolyHook_2_0/asmtk'...
remote: Enumerating objects: 501, done.        
remote: Counting objects: 100% (53/53), done.        
remote: Compressing objects: 100% (40/40), done.        
remote: Total 501 (delta 14), reused 22 (delta 12), pack-reused 448        
Receiving objects: 100% (501/501), 169.30 KiB | 1.20 MiB/s, done.
Resolving deltas: 100% (287/287), done.
Cloning into '/home/user/Documents/Source/c++/project/depends/PolyHook_2_0/zydis'...
remote: Enumerating objects: 9301, done.        
remote: Counting objects: 100% (265/265), done.        
remote: Compressing objects: 100% (150/150), done.        
remote: Total 9301 (delta 145), reused 186 (delta 101), pack-reused 9036        
Receiving objects: 100% (9301/9301), 15.28 MiB | 9.15 MiB/s, done.
Resolving deltas: 100% (6446/6446), done.
Submodule path 'asmjit': checked out 'a4cb51b532af0f8137c4182914244c3b05d7745f'
Submodule path 'asmtk': checked out '7ed7c9f127f39f54c3815e500cabe9bbb3e7bade'
Submodule path 'zydis': checked out '4022f22f9280650082a9480519c86a6e2afde2f3'
Submodule 'dependencies/zycore' (https://github.com/zyantific/zycore-c) registered for path 'zydis/dependencies/zycore'
Cloning into '/home/user/Documents/Source/c++/project/depends/PolyHook_2_0/zydis/dependencies/zycore'...
remote: Enumerating objects: 1271, done.        
remote: Counting objects: 100% (178/178), done.        
remote: Compressing objects: 100% (81/81), done.        
remote: Total 1271 (delta 103), reused 109 (delta 83), pack-reused 1093        
Receiving objects: 100% (1271/1271), 412.20 KiB | 1.92 MiB/s, done.
Resolving deltas: 100% (808/808), done.
Submodule path 'zydis/dependencies/zycore': checked out '6c93d9a38e62d4db82f99bf99159e1ee78341e36'
[user@fedora depends]$ mv PolyHook_2_0/ polyhook
[user@fedora depends]$ cd ..
[user@fedora project]$ cmake "./depends/polyhook" -B"./_build/polyhook" -DCMAKE_INSTALL_PREFIX="./_install/" -DPOLYHOOK_BUILD_SHARED_LIB=ON -DPOLYHOOK_FEATURE_INLINENTD=OFF
-- The C compiler identification is GNU 12.2.1
-- The CXX compiler identification is GNU 12.2.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test __CxxFlag__fno_threadsafe_statics
-- Performing Test __CxxFlag__fno_threadsafe_statics - Success
-- Performing Test __CxxFlag__fno_semantic_interposition
-- Performing Test __CxxFlag__fno_semantic_interposition - Success
-- Performing Test __CxxFlag__fmerge_all_constants
-- Performing Test __CxxFlag__fmerge_all_constants - Success
-- Performing Test __CxxFlag__fno_enforce_eh_specs
-- Performing Test __CxxFlag__fno_enforce_eh_specs - Success
** AsmJit Summary **
   ASMJIT_DIR=/home/user/Documents/Source/c++/project/depends/polyhook/asmjit
   ASMJIT_TEST=FALSE
   ASMJIT_TARGET_TYPE=STATIC
   ASMJIT_DEPS=pthread;rt
   ASMJIT_LIBS=asmjit;pthread;rt
   ASMJIT_CFLAGS=-DASMJIT_STATIC
   ASMJIT_PRIVATE_CFLAGS=-Wall;-Wextra;-Wconversion;-fno-math-errno;-fno-threadsafe-statics;-fno-semantic-interposition;-DASMJIT_STATIC
   ASMJIT_PRIVATE_CFLAGS_DBG=
   ASMJIT_PRIVATE_CFLAGS_REL=-O2;-fmerge-all-constants;-fno-enforce-eh-specs
** AsmTK Summary **
   ASMTK_DIR=/home/user/Documents/Source/c++/project/depends/polyhook/asmtk
   ASMJIT_EXTERNAL=FALSE
   ASMTK_TEST=
   ASMTK_TARGET_TYPE=STATIC
   ASMTK_CFLAGS=-DASMTK_STATIC
   ASMTK_PRIVATE_CFLAGS=-Wall;-Wextra;-Wconversion;-fno-math-errno;-fno-threadsafe-statics;-DASMTK_STATIC;-DASMJIT_STATIC
   ASMTK_PRIVATE_CFLAGS_DBG=
   ASMTK_PRIVATE_CFLAGS_REL=-O2
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY - Success
-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY - Success
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR - Success
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- Configuring done (3.0s)
-- Generating done (0.0s)
-- Build files have been written to: /home/user/Documents/Source/c++/project/_build/polyhook
[user@fedora project]$ cmake --build "./_build/polyhook" --config Release --target INSTALL
gmake: *** No rule to make target 'INSTALL'.  Stop.
stevemk14ebr commented 1 year ago

I can reproduce. I am not sure of the correct fix, linux support is best effort. If you find a fix please submit a PR

fligger commented 1 year ago

Hey, I do not know how to solve the "build and Install script" issue but Polyhook does build on linux after this pr merge

With cmake you can use polyhook as a subdirectory. Here are some instructions I Hope they help someone:

1. git clone PolyHook

Open your project root directory and git clone PolyHook to any subdirectory:

git clone --recursive https://github.com/stevemk14ebr/PolyHook_2_0.git

2. open your projects "CMakeLists.txt"

Add the add_subdirectory and target_link_libraries command

cmake_minimum_required(VERSION 3.15.0) # this is very stripped down
project(project)

add_subdirectory(PolyHook_2_0) # path to cloned repo

add_library(project SHARED project.cpp)

#link with dependencies
#include directories will be resolved automatically
target_link_libraries(project PolyHook_2) 

3. Build your project as usual

everything should work.

stevemk14ebr commented 1 year ago

That's a typical cmake submodule, good to know that works. I will try to fix the linux install target at some point. I'm a little confused why it doesn't work, as it works for vcpkg on windows

stevemk14ebr commented 1 year ago

The issue is the capitalization apparently, this works:

cmake --build "./_build" --config Release --target install