Hello,
Is there a way to add another path to the default search path for libraries? Or what argument do I pass and specify the path to search?
I tried: nim c --path:/opt/homebrew/lib/ --run --define:nimDebugDlOpen myfile.nim
It always fails even though the lib is present.
Hint: /Users/user/Desktop/myfile [Exec]
dlopen(libSDL2.dylib, 0x0002): tried: 'libSDL2.dylib' (no such file), '/usr/local/lib/libSDL2.dylib' (no such file), '/usr/lib/libSDL2.dylib' (no such file), '/Users/user/Desktop/libSDL2.dylib' (no such file)
could not load: libSDL2.dylib
Use --passL to add options to link, e.g.
--passL="-L/your/lib/path"
Thanks.
I tried your suggestion like so. nim c --passL:"-L/opt/homebrew/lib" --run --define:nimDebugDlOpen myfile.nim
It still did not search the path.
Hint: /Users/user/Documents/nim/myfile [Exec]
dlopen(libSDL2.dylib, 0x0002): tried: 'libSDL2.dylib' (no such file), '/usr/local/lib/libSDL2.dylib' (no such file), '/usr/lib/libSDL2.dylib' (no such file), '/Users/user/Documents/nim/libSDL2.dylib' (no such file)
could not load: libSDL2.dylib
Error: execution of an external program failed: '/Users/user/Documents/nim/myfile '
I don't know what defines the hard coded search paths of /usr/local/lib /usr/lib.
Also, I would expect the binary after compilation to list the lib dependency.
Terminal Output
$ otool -L myfile
myfile:
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.100.3)
No apologies necessary. Really appreciate the help.
I am still seeing same issue with setting the externs.
I am not sure, but something seems wrong with the executable. I pointed out earlier there is no dependency to link to libSDL2.dylib. It purely is being suggested for linking during runtime (which I don't know how or where this is specified).
Something is supplying paths to the dlopen command.
dlopen("/opt/homebrew/lib/libSDL2.dylib", 2)
Where do I specify?
dlopen("/opt/homebrew/lib/libSDL2.dylib", 2)
This is the content from myfile.nim.
import pixels
putPixel(5, 9)
putPixel(11, 18, Red)
NVM. Question closed.
I had tried appending. to $DYLD_LIBRARY_PATH and it actually worked this time.
Thanks all.