Search code examples
homebrewfactor-lang

Is there a way to change which location Factor looks for Homebrew libraries in?


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


Solution

  • I ended up finding the solution to my own question after some trial and error and help from the Factor Discord.

    • If running on an 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.