Search code examples
c++clinkerhookdylib

Undefined symbols for architecture x86_64: referenced from subhook-9679a6.o


Error:

"subhook_unprotect(void*, unsigned long)", referenced from:
      _subhook_new in subhook-9679a6.o
ld: symbol(s) not found for architecture x86_64

Linking command: g++ -dynamiclib -fPIC -v -o finalcalling.dylib finalversion.cpp /Users/~/Desktop/c/subhook-master/subhook.c -std=c++11

After going through my code I found that subhook_unprotect(void*, unsigned long) is not even in my code.


Solution

  • If this is your code https://github.com/Zeex/subhook then it seems you are supposed to also include subhook_unix.c in your build. That file does define subhook_unprotect. So does subhook_windows.c but I'm assuming you are on a unix like platform.