How OpenCL chooses which vendor's library to link @ runtime?

I am a little naive with how this works, I was hoping to get some clarification here.

Say I have a PC with an intel CPU and an AMD GPU. From what I understand, there will be implementations of the OpenCL standard provided by both Intel and AMD.

In my OpenCL program, I should see two separate platforms, one platform has the Intel device, the second platform has the AMD device.

I go on to write code to utilize both devices, compile program, etc…

I typically code on a Linux platform, and understand how to write a Makefile which gives the right include paths and link directories. I would like to know specifically, when I execute my program, how does it know which OpenCL libraries to link with? What is the process it uses to find these libraries?

The point is, you never directly link against the vendor implementation of the OpenCL functions. You link against some libOpenCL.so that fills out function pointer tables to the actual implementations at run-time and forwards the calls depending on which context you created. You can read about the so-called ICD mechanism here.

This is exactly what I was looking for, thanks!