ubuntu升级第三方库

问题:
/usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.20’ not found (required by layout)

解决方式:
测试依赖:
strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBCXX

升级方法:

1
2
3
4
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade

ppa 速度慢解决
将/etc/apt/sources.list 中
http://ppa.launchpad.net替换为https://launchpad.proxy.ustclug.org

ubuntu增加交换区

Process to Increase Size of Swap Partition and use it for Hibernation
Creating the swap partition
Activating the swap partition
Making the new swap partition work for hibernate (optional)
Creating the swap partition
Boot to Ubuntu install CD and choose the option to run Ubuntu now
Go to system -> GParted Partition Editor

Delete the swap partition and, if there is nothing else in it, the extended partition that holds it. (If by some miracle you’re able to resize your swap partition from here, I imagine your life will be a lot easier than mine.)
Decrease the size of your primary partition by the amount you want your new swap to be (I made mine 2x RAM + 500MB just to be safe). The easiest way to do this is to fill in the amount of space you want swap to be in the “free space following” field
In the free space that has now been created, choose new, type linux-swap and you can name the partition “swap” if you like
Hit the Apply button (should be a check mark) to write the changes to disk
When done, reboot back into Ubuntu
Activating the swap partition
(If your swap is on your primary hard drive, you don’t need to do anything here.) Now you need to find what partition your swap is on and what its UUID is. UUID?! you say? Well that’s the Universally Unique IDentifier for the partition so you can reference it even if it’s on a different mount point from boot-to-boot due to adding disks, etc.

Pull up a terminal and run gksu gparted & and enter your root password. The & lets this process run while still giving you access to the command line.

Right-click on your swap partition and choose Information. You should see the Path and UUID listed there. Keep this open for further reference.
Run gksu gedit /etc/fstab & and look for the line that has swap in it. It should be the third column, separated by spaces or tabs. You can either use the path or the UUID to tell Linux where to find your swap partition. I recommend UUID because it’ll stay constant even if you move the partition around or the disk somehow becomes sdb instead of sda or something like that. Make the appropriate edits and save the file. Your line should look something like this if you used UUID (with your UUID instead, of course):

UUID=41e86209-3802-424b-9a9d-d7683142dab7 none swap sw 0 0

or this if you used path: /dev/sda2 none swap sw 0 0

Save the file.
Enable the new swap partition with this command.

sudo swapon –all
OR

$ sudo swapon –all –verbose
swapon on /dev/sda2
swapon: /dev/sda2: found swap signature: version 1, page-size 4, same byte order
swapon: /dev/sda2: pagesize=4096, swapsize=2147483648, devsize=2147483648
Confirm that the swap partition exists.

$ cat /proc/swaps
Filename Type Size Used Priority
/dev/sda2 partition 2097148 0 -1
Reboot to make sure the new swap gets activated properly at startup

ubuntu中java虚拟机内存分配不足

问题:

ubuntu 虚拟机中,编译 android10,出现如下错误:
OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000769400000, 295698432, 0) failed; error=’Not enough space’ (errno=12)

解决方式:

方法一

最后来根据 (errno=12)这个搜索到一篇文章,说道:
    后来看了美军一个文章(http://www.enchantedage.com/node/235),加一个配置即可:echo 1000000 > /proc/sys/vm/max_map_count

我看了自己虚拟机 ubuntu 里面,/proc/sys/vm/max_map_count 的初始值很小,只有 65530,果断使用这个重设了一下。
  啊,终于好了,太艰难了。

后来又请装双系统的同事看下他们系统里的这个值,也是 65530,但是他们的却不报错,真是醉醉的。看来造成“无法分配内存”的原因,并不是这里,但是可以通过修改这个来解决。

猜测这个原因:1、双系统和虚拟机不同 2、安装 jdk 方式的不同(之前的我,和现在的同事们,都是先下载好 jdk 再安装的;可是现在虚拟机我却使用命令安装,这样不需要配置环境变量)

只是猜测,暂时就不去验证它了,如果再有遇到的同学,解决不了的话,可以朝这个方向尝试下。

方法二:

https://www.cnblogs.com/schips/p/solve_a_problem_of_Not-enough-space_when_building_android.html

编译rk3399板子android10系统(ubuntu22.4)

  1. 前提条件
    编译主机内存至少 12G,交换内存 10G(swapfile),磁盘空间 150G

  2. 解压 android10
    cat rk_android_10_sdk.tar.gz* | tar xzvf

  3. 进入解压根目录
    cd rk_android_10_sdk

  4. 切换终端
    exec bash
    注意:zsh 会有问题

  5. 安装 openjdk8

  6. 安装 python2.7
    sudo apt install python2.7

  7. 安装基础库

1
2
3
sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip libssl-dev gawk liblz4-tool

sudo apt-get install libncurses5 libncurses5:i386
  1. 执行 sh javaenv.sh

  2. 执行 source build/envsetup.sh

  3. 执行 lunch
    出现菜单中,选择 6 rk3399_Android10-userdebug

  4. 如果修改 framework,需要
    make api-stubs-docs-update-current-api

  5. 执行 ./build.sh -UKAu

常见问题

  1. GLIBCXX_3.4.21 not defined in file libstdc++.so.6 with link time reference
1
2
3
4
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-5
sudo apt-get upgrade libstdc++6

ubuntu关闭zsh

终端执行 exec bash

ubuntu安装python3.8-ssl

  1. 下载 openssl
    https://www.openssl.org/source/old/1.1.1/openssl-1.1.1d.tar.gz
    注意:python3.8 最好下载高版本 openssl
  2. 编译 openssl
1
2
3
4
5
6
tar zxvf openssl-1.1.1d.tar.gz openssl-1.1.1d
cd openssl-1.1.1d
sudo ./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl
sudo make
sudo make test
sudo make install
  1. 将编译后 openssl 动态库,加入搜索路径
1
2
3
4
5
6
7
sudo mkdir lib64
sudo ln -s /usr/local/openssl/lib/libssl.so.1.1 /usr/lib64/libssl.so.1.1
sudo ln -s /usr/local/openssl/lib/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1
sudo su
echo "/usr/lib64" >> /etc/ld.so.conf.d/lib64.conf
// 查看是否成功
ldconfig -v
  1. 下载 python3.8.5
    https://www.python.org/downloads/source/
  2. 解压 python
1
2
3
tar zxvf python3.8.5.tar.gz python3.8.5
cd python3.8.5
sudo apt-get install libffi-dev
  1. 修改配置
    vi modules/Setup
    放开如下注释:
1
2
3
4
SSL=/usr/local/openssl
\_ssl \_ssl.c \
-DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
-L$(SSL)/lib -lssl -lcrypto
  1. 编译 python
1
2
3
4
sudo ./configure --prefix=/usr/local/python
sudo make
sudo make install

  1. 加入动态管理 python
1
2
sudo update-alternatives --install /usr/bin/python python /usr/local/python/python3.8.5/bin/python3.8 3
sudo update-alternatives --config python

jenkins部署iOS打包环境

  1. 安装最新 Xcode
  2. 安装 cocoapod
    sudo gem install -n /usr/local/bin cocoapods
  3. 安装 rvm
    curl -sSL https://get.rvm.io | bash -s stable
    rvm install 3.1.2
    rvm use 3.1.2 --default
  4. 安装 fastlane
    sudo gem install fastlane
  5. 配置 git
    1)是通过 http/https 访问 git,配置免密登录
    在当前登录用户根目录,如/Users/mac
    touch .git-credentials
    文件中,存入如下:
    1
    http://huang:huang123@10.168.66.55
    格式为:http://账号:密码@域名
    touch .gitconfig
    文件中,存入如下:
    1
    2
    [credential]
    helper = store
  1. 是通过 ssh 访问 git,创建好公私钥,具体配置是百度,不做具体说明
  1. 钥匙串中安装 iOS 部署证书
  2. jenkins 打包脚本中增加,用于解开钥匙串
    security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k password ~/Library/Keychains/login.keychain-db

android多路摄像头

原生 Android-Camera 类打开一个摄像头没有问题,打开多个会在 open()的时候报错。

注意原生 camera 要在 surface 之后在 open,否则会报错。也就是说不要直接在 oncreate 里 open。(相机 Open 前要设置 surface ,这个 surface 就是底层用来渲染预览画面的,如果 surface 都没有 create ,底层将无法渲染,我想这就是为什么 open 不了的原因吧)参考:https://bbs.csdn.net/topics/390940480

理论上,好像原生 camera 最大支持打开两个摄像头,可以参考这个代码去实现:

https://blog.csdn.net/a87636764/article/details/54645350

当然也可以看下面这个代码(比较全):

https://blog.csdn.net/CrossFile_TMS/article/details/75258570

但实际打开第二个我就报错了,报错内容:

W/CameraBase: An error occurred while connecting to camera: 1

java.lang.RuntimeException: Fail to connect to camera service

试了很多次都不行,果断放弃了原生 Camera 的思路,转向了 UVC 的方向:(下面详细写了,先膜拜一下 orz)

可以看下这个大哥的实现:https://blog.csdn.net/yyfd2013/article/details/85321175

UVCCamera 项目在 open 位置又报错了:解决 UVCCamera 项目报错:could not open camera:err=-1

参考地址:https://www.jianshu.com/p/21e95f2f1206

———————————— 我是分界线 ————————————

我去,总算搞出来了,看了一天的源码,调了一天的 bug。。。。。。

效果图如下:

主要参考了下面的项目:

UVC-Github 项目源码地址:https://github.com/saki4510t/UVCCamera

然后能搜到的是下面这两个博客:

单摄像头 github:https://github.com/jiangdongguo/AndroidUSBCamera

单摄像头 CSDN:https://blog.csdn.net/andrexpert/article/details/78324181


多路摄像头 github:https://github.com/yyfd2013zy/UvcCameraDemo

多路摄像头 CSDN:https://blog.csdn.net/yyfd2013/article/details/85321175


然后这篇文章是解析了代码,但我还是希望小伙伴们能自己去看源码,自己去消化,别人的始终不是自己的:

https://www.jianshu.com/p/9108ddfd0a0d

其中,学习的话我更偏向于多路摄像头那个项目,他用的是源码导入;而单摄像头的项目是作者自己封装了,并且我的直观感受是和源项目结构差不多,这样一封装层级结构更多了,查找源码找 bug 太复杂了。。。不过单摄像头的项目功能封装的比较多一些。

我的需求是多路摄像头的可视化 + 拍照,并且是 IOT 设备,所以倾向于多路摄像头项目。

没有不经历汗水就能拿到奖的人,资料和学习路线我都放上面了,剩下的坑要自己去趟了!

———————————— 我还是分界线 ————————————

环境:rk3288 5.1 海康摄像头


填坑之路:

首先像这么复杂的项目导入肯定是编译不过。。。一定要看清楚原博主写的经验:

传送门:https://blog.csdn.net/momo0853/article/details/73898066 看了,和官网一样,墙内用户放心下。

项目配置好 NDK 路径(是项目,别把 android studio 改了。。),clean 一下应该就没问题了。

项目跑起来之后,你会发现。。。是黑屏的。。。(一般是)

这个只能说自己的硬件,自己写日志慢慢调试吧,不同的摄像头和主板肯定不一样。项目的核心关键类是:UVCCamera

问题基本出现在下面几个方面:

1.分辨率。看源码,默认分辨率是 640*480,要看你的摄像头支不支持,不支持的话会打开成功,但是黑屏。

2.首选 FRAME_FORMAT_MJPEG,可以都换成这个试一试,如果不行,再换 FRAME_FORMAT_YUYV。我是全部 FRAME_FORMAT_MJPEG 就可以了。

3.因为各种原因导致的 open 错误,可以看英文解释:

github:https://github.com/worlfChina/UVCCameraDemo

下载后请更换项目 NDK 为您本地 r14 版本。

mac安装sshpass

  1. sshpass: 用于非交互的 ssh 密码验证
  2. SSH 登陆不能在命令行中指定密码,也不能在 shell 中随处可见的。sshpass 的出现,解决了这一问题。它允许你用 -p 参数指定明文密码,然后直接登录远程服务器。它支持密码从命令行、文件、环境变量中读取。
  3. mac 下安装(需要有 xcode 和 command-lines 工具)
1
2
3
4
curl -O -L  https://fossies.org/linux/privat/sshpass-1.09.tar.gz && tar xvzf sshpass-1.09.tar.gz
cd sshpass-1.09/
./configure
sudo make install
  1. 使用命令
    sshpass -p password ssh user@111.111.1.1

在 iTerm 中使用 rz/sz 传输文件

在 Mac 上安装 lrzsz

1
$ brew install lrzsz

在 Mac 上新建 shell 脚本

1
2
3
4
5
6
7
$ touch /usr/local/bin/iterm2-recv-zmodem.sh
$ touch /usr/local/bin/iterm2-send-zmodem.sh
``

内容参考 [github](https://links.jianshu.com/go?to=https%3A%2F%2Fgithub.com%2Fsnow-sprite%2Frzsz)

完成脚本创建后,为脚本添加可执行权限。

$ chmod a+x /usr/local/bin/iterm2-recv-zmodem.sh
$ chmod a+x /usr/local/bin/iterm2-send-zmodem.sh

1
2
3
4
5
配置 iterm2
`Preferences -> Profiles -> Default -> Advanced -> Triggers`
![](iterm1.webp)
![](iterm2.webp)
新增两条记录,Regular Expression 和 Parameters 分别是

rz waiting to receive.**B0100 /usr/local/bin/iterm2-send-zmodem.sh
**B00000000000000 /usr/local/bin/iterm2-recv-zmodem.sh

1
2
3
4
5
6
7
8
9
10

注意,Action 需要选择 Run Silent Coprocess...,并勾选 Instant。

使用命令
使用 ssh 连接到服务器后,输入 rz,会弹窗选择文件,即可将本地文件传输到服务器。
`rz`

使用 sz xxxx.jar,会弹窗选择目录,即可将服务器的文件传输到本地。
`sz xxxx.jar`