Raspberry Pi 4: Where to put raylib after I've compiled it to get dub to find and link properly

Mike Parker aldacron at gmail.com
Mon Mar 8 04:22:14 UTC 2021


On Monday, 8 March 2021 at 03:16:40 UTC, Decabytes wrote:
> I just downloaded Raylib on the pi 4, which unfortunately 
> wasn't in the repo on Raspberry Pi OS. On my computer main 
> comp, I can link it by just adding raylib to the libs section 
> of the dub.sdl because I downloaded it from the repo, but 
> because I've compiled it from source on the RPI that doesn't 
> work. All the files are located at /home/pi/Desktop/raylib/src. 
> I've tried variations of /home/pi/Desktop/raylib/src and 
> /home/pi/Desktop/raylib, but I can't seem to get it to work. Is 
> there a place I can put the code so that the original libs 
> "raylib" line will work? Or is there just a different way to 
> link it I'm not understanding? I don't really understand how 
> linking works

The linker needs to know two pieces of information to link 
library dependencies: the library name, and the path to the 
library. The "libs" directive in the dub.json handles the name.

Every operating system has a default library search path. If the 
library is not on that search path, then you'll need to specify 
the path. In your dub.json, you should be able to do this with an 
"lflags" directive, using "-L/path/to/lib". The path can be 
absolute or relative to the directory in which you're compiling.

However, on Unix-like systems, libraries are usually installed in 
a well-known location on the default search path, like /usr/lib 
or /usr/local/lib. The raylib Makefile has an "install" target, 
so you should be able to run "make install" to put the library in 
the right place. Or you can copy it manually.


More information about the Digitalmars-d-learn mailing list