wolfcw / libfaketime

libfaketime modifies the system time for a single application
https://github.com/wolfcw/libfaketime
GNU General Public License v2.0
2.64k stars 321 forks source link

why i can not run libfaketime under macos? #380

Closed minikiller closed 2 years ago

minikiller commented 2 years ago

I build libfaketime from github source code , and also export environment variant as following:

export DYLD_FORCE_FLAT_NAMESPACE=1
export DYLD_INSERT_LIBRARIES=/usr/local/lib/faketime/libfaketime.1.dylib
export FAKETIME="@2022-03-28 22:21:21" 

but when I run my app , i get following error message:

dyld[1250]: terminating because inserted dylib '/usr/local/lib/faketime/libfaketime.1.dylib' could not be loaded: tried: '/usr/local/lib/faketime/libfaketime.1.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/usr/lib/libfaketime.1.dylib' (no such file)
dyld[1250]: tried: '/usr/local/lib/faketime/libfaketime.1.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/usr/lib/libfaketime.1.dylib' (no such file)

I am also run testing under test directory. All works, I don't know why? Please help me to solve this problem. Thanks!

wolfcw commented 2 years ago

It seems like libfaketime was compiled for an ARM architecture (such as Apple's M1 CPU), but you try to run it on an Intel x86_64 system or for a x86_64 application.

You can try setting

export FAKETIME_COMPILE_CFLAGS='-arch arm64 -arch x86_64'

and recompiling, and might want to check #334 for other options regarding multi-platform compilation. We don't have a final solution over there, except that when using Rosetta 2, I never was able to reproduce any of the problems no matter which platform I used for libfaketime in combination with whatever platform of the target application. :-/

wolfcw commented 2 years ago

Please re-open with additional info if the problem persists.