CUDAbyExample环境搭建

git clone https://github.com/CodedK/CUDA-by-Example-source-code-for-the-book-s-examples-.git

首先是报错

nvcc -o ray ray.cu 
In file included from ../common/cpu_bitmap.h:20:0,
                 from ray.cu:19:
../common/gl_helper.h:44:21: fatal error: GL/glut.h: No such file or directory
 #include <GL/glut.h>

google后发现需要

sudo apt-get install  freeglut3-dev

然而出现众多依赖报错

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 freeglut3-dev : Depends: libgl1-mesa-dev but it is not going to be installed or
                          libgl-dev
                 Depends: libglu1-mesa-dev but it is not going to be installed or
                          libglu-dev
                 Depends: libxext-dev but it is not going to be installed
                 Depends: libxt-dev but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

尝试update,但遇到

Err:7 https://cli.github.com/packages stable InRelease                                                                             
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 23F3D4EA75716059

一共有两个key错误.按照这里提供的方法输入

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 23F3D4EA75716059

和另一个,另外一个解决,但这个仍然无法解决.根据这里提供的方法,输入

curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
&& sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& sudo apt update \
&& sudo apt install gh -y

update的问题正常.似乎是密钥未注册.然而freeglut3-dev仍然不能安装,绷.

放弃unix,转向Windows.首先是报错

LINK : fatal error LNK1104: 无法打开文件“glut64.lib”

解决方法是将代码自带的lib文件夹下的glut64.lib复制到代码所在目录(作者你太贴心了).继续编译不会报错,但运行.exe文件时会提示找不到glut64.dll.经多方搜索,解决方法为在VS的bin目录下粘贴代码目录下的bin文件夹内的这个文件.目标目录为C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\bin\Hostx64\x64\.注意可能随安装版本不同而有所变化.(PS:我不知道直接将glut64.dll复制到代码目录是否有用,或可一试)

posted @ 2023-02-16 19:50  LinXiaoshu  阅读(154)  评论(0)    收藏  举报