生词之typo和globbing

typo:

打字时,按错键,打出错字,可以说打出typo了,很好记,就是type错打成typo了。

globbing:

计算机术语为通配符的意思。比如,cmake中,add_library命令中的路径名是不能用通配符的,必须先用cmake提供的file命令收集路径名到一个变量中,再将此变量赋给add_library,像这样:

1
2
3
4
5
6
7
8
file(GLOB srcs
	path1/example1/*.cpp
	path2/*.cpp
)
 
add_library(lib1
	${srcs}
)

看到其中的GLOB了没?

include_directories clean 清空

1,如果include_directories(dirA)写在add_subdirectory(dirB)之前,dirB目录的CMakeLists.txt会继承dirA的值。

2,如果include_directories(dirA)写在add_subdirectory(dirB)之后,dirB目录的CMakeLists.txt会不继承dirA的值。

所以所谓清空就是用方法2了。

placement new

代码直接在gcc里是可以编译通过的,在vc里编译,注意,如果是将例子代码加到MFC程序里,要注释掉源码中的DEBUG_NEW:

1
2
3
4
5
/*
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
*/

代码如下:

Read more

cannot open shared object file

1. setup LD_LIBRARY_PATH

1
export LD_LIBRARY_PATH=/where/you/install/lib:$LD_LIBRARY_PATH

2. modify /etc/ld.so.conf,add /where/you/install/lib, then

1
sudo ldconfig

cmake 显示编译命令

1
make VERBOSE=1

或者CMakeLists.txt中加上:

1
set(CMAKE_VERBOSE_MAKEFILE ON)

用tar备份linux文件系统

1
2
cd /
tar cvpjf backup.tar.bz2 --exclude=/proc --exclude=/lost+found --exclude=/backup.tar.bz2 --exclude=/mnt --exclude=/sys /

制作rootfs.img

1
git clone https://github.com/friendlyarm/debian_nanopi2

在debian_nanopi2目录内新建rootfs目录,将一个已经装好程序的板子里所有文件及目录打包,方法见:

用tar备份linux文件系统

再解压到此rootfs目录,再执行build.sh,它会调用debian_nanopi2/tools/make_ext4fs生成rootfs.img

由于make_ext4fs为32位的,可能系统为64位,则要安装32位支持库:

1
2
3
4
apt-get install lib32ncurses5
apt-get install lib32z1
apt-get install libstdc++6
apt-get install lib32stdc++6

生成rootfs.img后,则可以替换eflasher img里的对应文件,再刷机。详情见:

http://wiki.friendlyarm.com/wiki/index.php/EFlasher/zh

但是,此wiki页面中提供的刷机包有可能存在问题,可以直接下官方百度盘里的刷机包,比如:

https://pan.baidu.com/s/1kVySP6Z/#list/path=%2FFriendlyARM-S5P6818

里面的s5p6818-eflasher-sd8g-20171102-full.img.zip,在Windows里,刷到SD卡后,安全卸载SD卡,再插上,直接把做好的rootfs.img替换SD卡的fat分区里的对应文件就可刷机了。

此方法适用于nanopc t2和nanopc t3。

修改interfaces文件重启网络还是启动不了

比如,修改/etc/network/interfaces为这样

1
2
3
4
5
6
auto eth0
iface eth0 inet static
address 192.168.1.38
gateway 192.168.1.1
netmask 255.255.255.0
dns-nameservers 192.168.1.1

保存再重启,发现网络还是不通,经测试,是要去掉最后一行

1
#dns-nameservers 192.168.1.1

保存再重启,网络就通了。