之前遇到过这个问题,当时费了很大的劲才解决,今天因为重新烧录了镜像,又需要重新解决这个问题,但是有了上次的经验,很快就解决了,这里把步骤记录一下:
我们在Linux开发板中编译代码的时候,会用到/lib/modules/xx/build这个目录,但是有时候这个目录不存在,解决办法就是要安装Linux-headers,方法如下:
第一步:
sudo apt-get install build-essential //install build-essential(optional)
sudo apt-get update //install linux-headers
sudo apt-get install linux-headers-$(uname -r)
按照网上说法,执行上面命令后应该就好了,但是本人在尝试的时候,出现了以下错误:
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package linux-headers-4.19.71-imx-r1
E: Couldn't find any package by glob 'linux-headers-4.19.71-imx-r1'
E: Couldn't find any package by regex 'linux-headers-4.19.71-imx-r1'
提示无法locate package,这时我们进行第二步,输入下面两条命令,
第二步:
echo "deb https://seeed-studio.github.io/seeed-linux-deb/ buster main" | sudo tee /etc/apt/sources.list.d/seeed.list
curl -k https://seeed-studio.github.io/seeed-linux-deb/public.key | sudo apt-key add -
然后再
sudo apt update
sudo apt install linux-headers-4.19.71-imx-r1
在update的时候看到Reading package lists... Done才算成功
问题到这里就应该可以解决了。
不过我上次在这里update的时候还有问题,提示public key有问题,具体是什么问题我已经记不清了,不过这个问题很好解决,搜一下它出现的错误提示即可。
其实第二步可能是会难住很多人,因为这个答案出现在一个英文的网站里面,还比较隐蔽,所以今天记录一下,免得掉坑。
参考:
https://blog.csdn.net/miaoyanmm/article/details/79853297
https://unix.stackexchange.com/questions/614686/npi-i-mx6ull-linux-sbc-difficulty-finding-linux-headers