Hi there, I just took a few days to make it work myself,
Many of the tutorials online will tell you to use the addon.retroarch/rom.sh script to run the games.
After some hassle and work, I will tell you how I got it working on LibreELEC v 8.2.2 (Generic) and RetroArch addon from retrolib v. 8.169.7.
I assume you already installed the retroLib repository to kodi and now want to run the games via commandline.
When you create a new Collection for the Rom Collection Browser, we want to select the Retroarch executables as the emulator with a specific paramater stating it where to find the Core it should run with the emulator for the ROM.
From a Command line we can test this (you can ssh into the device and run the command to test that this would work) as follows:
/storage/.kodi/addons/game.retroarch/game.retroarch-Gen -L /storage/.kodi/userdata/addon_data/game.retroarch/cores/[Name of the Core we want to load] [Location and Name of the ROM]
So the first thing we want to do is enable hidden folders so we can point Rom Collector Browser to the game.retroarch-Gen file (If you are running the Arm/RPi version of LibreELEC, you will probably want to run game.retroarch-RPi, don't know, I haven't tried it.)
This can done in settings, Media, General and enable "Show hidden files and directories"
Then when Rom Collector browser requests for the Emulator, select the binary in the directory /storage/.kodi/addons/game.retroarch/game.retroarch-Gen
For the paramaters for the launcher we will have to manually input the location of the .so file, unless someone can give me a better way.
-L /storage/.kodi/userdata/addon_data/game.retroarch/cores/[Name of the Core we want to load] "%ROM%"
The name of the core will be divided by the collection, so ensure that for the SNES collection you are loading the snes9x_retrolib.so core etc.
Good luck and good gaming!