A
A
Alex Wells2018-05-27 21:01:13
C++ / C#
Alex Wells, 2018-05-27 21:01:13

Why don't MinGW and VS17 want to link detours.lib?

Hello. I'm trying to detour the function according to the guide, here's the code: *click github* . Actually, everything is fine, besides the fact that neither VS2017 nor the project with CMake + MinGW give the following errors:

D:/Detour-master/dll/dllmain.cpp:46: undefined reference to `DetourTransactionBegin'

The project folder contains detours.lib, but no one wants to link it. In the CMake project, I directly indicate this:
cmake_minimum_required(VERSION 3.9)
project(dll)

find_library(psapi "D:/ProgrammingNew/Win-builds/mingw/lib/libpsapi.a")
find_library(detours "D:/Detour-master/dll/detours.lib") # <------------------------ вот

set(CMAKE_CXX_FLAGS "-fpermissive -w")
set(CMAKE_CXX_STANDARD 17)

add_library(dll SHARED
        sigscan.h
        dllmain.cpp
        )

target_link_libraries(dll psapi)
#target_link_libraries(dll detours) # <------------------------ вот два

If you uncomment the lines, this will lead to the problem itself:
d:/programmingnew/win-builds/bin/../lib64/gcc/x86_64-w64-mingw32/4.8.3/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -ldetours

If you specify -LD: / Detour-master / dll in the compiler arguments, this will come out:
d:/programmingnew/win-builds/bin/../lib64/gcc/x86_64-w64-mingw32/4.8.3/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible D:/Detour-master/dll/detours.lib when searching for -ldetours
d:/programmingnew/win-builds/bin/../lib64/gcc/x86_64-w64-mingw32/4.8.3/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible D:/Detour-master/dll/detours.lib when searching for -ldetours
d:/programmingnew/win-builds/bin/../lib64/gcc/x86_64-w64-mingw32/4.8.3/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible D:/Detour-master/dll\detours.lib when searching for -ldetours
d:/programmingnew/win-builds/bin/../lib64/gcc/x86_64-w64-mingw32/4.8.3/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -ldetours

Question: how to fix the last problem? The version of detours is 4.0, I tried with the one that comes with the repository, and with my own compiled one.
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question