I'm trying to use the disassembler capstone library in Factor but I get an error that Factor can't find the library:
Loading resource:basis/tools/disassembler/capstone/capstone.factor
IN: scratchpad : hello ( -- ) "hello" print ;
IN: scratchpad \ hello disassemble
Cannot resolve C library function
Library: DLL" libcapstone.dylib"
Symbol: cs_open
DlError: dlopen(libcapstone.dylib, 0x0009): tried: 'libcapstone.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibcapstone.dylib' (no such file), '/usr/lib/libcapstone.dylib' (no such file, not in dyld cache), 'libcapstone.dylib' (no such file)
See https://concatenative.org/wiki/view/Factor/Requirements
But Homebrew on Apple Silicon installs in /opt/homebrew/ not /usr/lib
Is there a way to change the location Factor looks for libraries in or the location that Homebrew installs libraries? I tried to copy the file as well but it didn't work (even with sudo):
command: cp /opt/homebrew/libcapstone.dylib /usr/lib/libcapstone.dylib
result: cp: /usr/lib/libcapstone.dylib: Operation not permitted
I ended up finding the solution to my own question after some trial and error and help from the Factor Discord.
arm64
machine (assuming Factor still doesn't have an arm64
compiler), your libcapstone.dylib
will likely be in /opt/homebrew
instead of in /usr/lib
where Factor expects it.
x86_64
version of homebrew on your machine (https://gist.github.com/progrium/b286cd8c82ce0825b2eb3b0b3a0720a0) , and then arch -x86_64 brew reinstall capstone
and rebuild Factor arch -x86_64 ./build.sh update