在 Ubuntu 上编译 OpenCL

发布于 2024-09-29 21:27:14 字数 208 浏览 6 评论 0原文

我的编程经验是高中时大约 1 年的 C/C++ 经验,但几个月前我做了研究并使用 OpenCL 编写了一个简单的程序。我能够使用 g++ 和 --framework 选项相对轻松地在 Apple 计算机上编译并运行它。现在我在我的 Ubuntu 机器上,我不知道如何编译它。正确的驱动程序已与 ATI 的 Stream SDK 一起下载(我有 ATI Radeon HD5870)。任何帮助将不胜感激!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

醉城メ夜风 2024-10-06 21:27:14

尝试

locate libOpenCL.so

如果它位于标准目录之一(很可能是 /usr/lib 或 /usr/local/lib),则需要将“--framework OpenCL”替换为“-lOpenCL”。如果 g++ 找不到该库,您可以通过添加“-L/path/to/library”告诉 g++ 在特定目录中查找。

我希望我的 Linux 能更有帮助...最好重新下载 ati-stream-sdk,解压后,打开终端并“cd /path/to/extracted/files”;在该目录中执行 make && sudo make install

  • make 你可能从windows就知道这个,这个编译,需要编译什么
  • && 将命令链接在一起,下面的命令只会如果第一个命令成功,则执行
  • sudo make install 这会将文件放在预期的位置(sudo 使用超级用户权限执行命令,您必须输入密码)

希望有所帮助。

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.

我很OK 2024-10-06 21:27:14

您可能缺少动态链接器配置中的动态库。

搜索图书馆在哪里。最有可能的是 /usr/lib 或 /usr/local/lib。

确保路径位置也配置在以下位置之一:

  • LD_LIBRARY_PATH - 您可以在环境 shell 中设置它,例如 .bashrc
  • /etc/ld.so.conf - 您将需要调用 ldconfig 来更新缓存,并且它需要root 访问权限来更改文件。

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.
临风闻羌笛 2024-10-06 21:27:14

原因

除了@bjoernz,我的系统找不到libOpenCL.so文件

这是因为缺少正确的文件目录

经过互联网搜索后,我发现libOpenCL.so code> 文件可以由 ocl-icd-opencl-dev 软件包提供

解决方案

只需要在 cmd 中输入安装上述软件包即可

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

,因此可以找到 libOpenCL.so/usr/lib/x86_64-linux-gnu/ 文件夹下

我的系统信息

  • 操作系统:Ubuntu 16.04 LTS
  • GPU:NVIDIA GeForce GTX 660
  • GPU驱动程序:nvidia-375
  • OpenCL:1.2

参考:

[1] 如何在ubuntu上安装libOpenCL.so

[2] 如何在 Linux 中设置 OpenCL

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文