user492268
user492268

Reputation: 83

Compiling OpenCL on Ubuntu

My programming experience is about 1 year of C/C++ experience from high school, but I did my research and wrote a simple program with OpenCL a few months ago. I was able to compile and run this on an Apple computer relatively easily with g++ and the --framework option. Now I'm on my Ubuntu machine and I have no idea how to compile it. The correct drivers have been downloaded along with ATI's Stream SDK (I have an ATI Radeon HD5870). Any help would be appreciated!

Upvotes: 8

Views: 21944

Answers (3)

WY Hsu
WY Hsu

Reputation: 1905

Reason

Aside from @bjoernz, my system can't find the libOpenCL.so file

It's because the correct file directory is missing

After searchig over the internet, I found out that libOpenCL.so file can provided by ocl-icd-opencl-dev package

Solution

You just need to install the package mentioned above by typing into cmd

sudo apt update
sudo apt install ocl-icd-opencl-dev

Therefore, libOpenCL.so can be found under /usr/lib/x86_64-linux-gnu/ folder

My System Information

  • OS: Ubuntu 16.04 LTS
  • GPU: NVIDIA GeForce GTX 660
  • GPU Driver: nvidia-375
  • OpenCL: 1.2

Reference:

[1] How to install libOpenCL.so on ubuntu

[2] How to set up OpenCL in Linux

Upvotes: 0

Paulo Pinto
Paulo Pinto

Reputation: 622

You might be missing the dynamic libraries from the dynamic linker configuration.

Search for where the libraries are. Most likely /usr/lib, or /usr/local/lib.

Make sure the path location is also configured at one of these places:

  • LD_LIBRARY_PATH - you can set it in you environment shell, like .bashrc
  • /etc/ld.so.conf - you will need to call ldconfig to update the cache and it requires root access to change the file.

Upvotes: 0

bjoernz
bjoernz

Reputation: 3852

Try

locate libOpenCL.so

If it is in one of the standard directories (most likely /usr/lib, or /usr/local/lib) you need to replace "--framework OpenCL" with "-lOpenCL". If g++ cannot find the lib you can tell g++ to look in a specific directory by adding "-L/path/to/library".

I wish I had my Linux to be more helpful... It is probably best if you redownload the ati-stream-sdk, after extracting it, open the Terminal and "cd /path/to/extracted/files"; in that directory execute make && sudo make install

  • make you probably know this from windows, this compiles, whatever needs to be compiled
  • && chains commands together, the following commands will only be executed if the first command succeeded
  • sudo make install this will put the files in the expected places (sudo executes a command with superuser priviledges, you will have to enter your password)

Hope that helps.

Upvotes: 8

Related Questions