I assume the linker doesn't find the library due to an issue in your setup.
It seems your script isn't fully executed as it contains
brew install primesieve;
echo $DYLD_LIBRARY_PATH;
sudo update_dyld_shared_cache;
nm /usr/local/lib/libprimesieve.dylib;
file /usr/local/lib/libprimesieve.dylib;
fpc dynlibdemo.pas;
but looks like it stops after doing echo $DYLD_LIBRARY_PATH;==> Downloading https://homebrew.bintray.com/bottles/primesieve-7.5.high_sierra.
######################################################################## 100.0%
==> Pouring primesieve-7.5.high_sierra.bottle.tar.gz
🍺 /usr/local/Cellar/primesieve/7.5: 24 files, 563.8KB
DYLD_LIBRARY_PATH
0.05s$ cd examples
The command "cd examples" exited with 0.
0.49s$ fpc -Fu../ nth_prime.pas
Free Pascal Compiler version 3.2.0 [2020/06/21] for x86_64
echo $DYLD_LIBRARY_PATH; should print the path you set.EDIT:
Just saw that you made some changes (so probably the current script doesn't match the the old job anymore) in your repo and thus there are new builds which contain more infos.
The issue is that you've a
/usr/local/lib/libprimesieve.dylib: Mach-O 64-bit dynamically linked shared library x86_64 but trying to link it statically. Use dynamic loading as you do in
dynlibdemo.pas and it'll work.