jmpews / Dobby

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

A compile error on Windows (building for Android) #232

Open JaanDev opened 1 year ago

JaanDev commented 1 year ago

Hello! I am using cmake to build a dynamic library (mod) for android armeabi-v7a. Im compiling from windows 10. My compiler is clang.

The error:

[build] ..../GDL/libs/dobby/builtin-plugin/SymbolResolver/macho/macho_ctx.h:5:10: fatal error: 'mach-o/loader.h' file not found
[build] #include <mach-o/loader.h>
[build]          ^~~~~~~~~~~~~~~~~
[build] 1 error generated.
... later ...
[build] In file included from ..../GDL/libs/dobby/builtin-plugin/SymbolResolver/macho/shared_cache_ctx.cpp:1:
[build] ..../GDL/libs/dobby/builtin-plugin/SymbolResolver/macho/shared_cache_ctx.h:2:10: fatal error: 'mach-o/loader.h' file not found
[build] #include <mach-o/loader.h>
[build]          ^~~~~~~~~~~~~~~~~
[build] 1 error generated.

it also cant include <mach-o/nlist.h> in the same macho_ctx.h

here is my CMakeLists.txt (it builds successfully without dobby)

cmake_minimum_required(VERSION 3.0.0)

# write path to ur android ndk into NDKPath.txt. Recommended version is r23c
# use / (not \ or \\)
file(STRINGS "NDKPath.txt" CMAKE_ANDROID_NDK)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/out)
set(CMAKE_SYSTEM_NAME Android)
set(CMAKE_SYSTEM_VERSION 21)
set(CMAKE_ANDROID_ARCH_ABI armeabi-v7a) # arm64-v8a / armeabi-v7a
set(CMAKE_ANDROID_STL_TYPE c++_static)
set(MODNAME GDL)

project(${MODNAME} VERSION 1.0.0)

add_subdirectory(libs/dobby)

file(GLOB SOURCES
    src/*.cpp
)

add_library(${MODNAME} SHARED ${SOURCES})

target_link_libraries(${MODNAME} log dobby)

install(TARGETS ${MODNAME} LIBRARY)
Naville commented 1 year ago

Fix: Wrap https://github.com/jmpews/Dobby/blob/b0176de574104726bb68dff3b77ee666300fc338/builtin-plugin/SymbolResolver/CMakeLists.txt#L39 in if(SYSTEM.Darwin) calls