笔记整理

1.g++编译时lib找不到:

/usr/bin/ld: cannot find -lcufft
/usr/bin/ld: cannot find -lnpps
/usr/bin/ld: cannot find -lnppi
/usr/bin/ld: cannot find -lnppc
/usr/bin/ld: cannot find -lcudart

已经设置了环境变量,仍旧报错
这是因为LD_LIBRARY_PATH是用于运行时的,编译时需要添加LIBRARY_PATH
在gcc/g++指令后添加 -L/usr/local/cuda-7.0/lib64

2.更换gcc/g++版本:
sudo update-alternatives –config gcc
sudo update-alternatives –config g++
如果在config里没有需要的版本选项,需要自己添加进去(最后的20是选默认编译器时的优先级):
sudo update-alternatives –install /usr/bin/g++ g++ /usr/bin/g++-5 20

删除所有gcc/g++:sudo update-alternatives –remove-all gcc

3.ubuntu关闭和开启图形界面:
sudo service lightdm stop
sudo service lightdm restart

4.ssh在局域网两台主机互相拷贝文件:
拷贝过去:scp sb.txt ubuntu@192.168.1.157:/home/ubuntu/
拷贝过来:scp ubuntu@192.168.1.157:sb.txt ~/

5.ubuntu结束进程:
例如要结束test进程
pgrep test
然后会得出一串数字,如2111
sudo kill 2111

6.linux修改udp缓冲区大小:
sudo gedit /etc/sysctl.conf
添加一行net.core.rmem_max=16384000 //数字可自己设置,实际可用大小为此处两倍
sudo sysctl -p 更新设置
cat /proc/sys/net/core/rmem_max 查看缓冲区大小

7.ubuntu挂载硬盘注意事项:
sudo fdisk -l 查看硬盘信息(是分区工具)
df -h 查看文件系统(分区)的使用情况的
sudo blkid 查看UUID
sudo fdisk /dev/sdb 创建新分区(要先在win下开辟一块空的空间)
创建完新分区后,sudo mkfs -t ext4 /dev/sdb7 将新分区格式化成ext4格式
用sudo e2label /dev/sdb7 /workExtend改变卷的名字
去/etc/fstab修改启动项
sudo chmod 777 /home/pc/EXTEND修改文件访问权限

8.TX1挂载SD卡:

$ sudo apt-get install exfat-fuse exfat-utils //治标不治本,exFAT格式
$ sudo mkfs.ext4 /dev/mmcblk1p1
$ lsblk

9.host上arm-gcc使用:

sudo gedit /etc/profile
export PATH=$PATH:/opt/FriendlyARM/toolschain/4.4.3/bin
source /etc/profile
arm-linux-gcc -v
arm-linux-gcc hello.c -o hello

10. cannot find -lopencv_dep_cudart:
在编译的时候要设置cmake选项:cmake .. -DCUDA_USE_STATIC_CUDA_RUNTIME=OFF

11.cmake找不到cuda解决方案:
方法一:设置环境变量,终端可通过
方法二:若在qt,clion等IDE里使用,需要在CMakeList.txt里
project( 项目名) 前加一行set(CUDA_TOOLKIT_ROOT_DIR “/usr/local/cuda-7.0”)

12.sudo不可用解决方法:
pkexec chmod 0440 /etc/sudoers
一般的pc版本pkexec是默认安装的

13.ubuntu卸载通过make install安装的库:
方法一:
cd path/build
make uninstall,但这个建立在有uninstall文件的情况下
方法二:
cd path/build
cat install_manifest.txt | sudo xargs rm (make install后都会有install_manifest.txt)

14.ubuntu查看cpu信息:

#!/bin/bash

physicalNumber=0
coreNumber=0
logicalNumber=0
HTNumber=0

logicalNumber=$(grep "processor" /proc/cpuinfo|sort -u|wc -l)
physicalNumber=$(grep "physical id" /proc/cpuinfo|sort -u|wc -l)
coreNumber=$(grep "cpu cores" /proc/cpuinfo|uniq|awk -F':' '{print $2}'|xargs)
HTNumber=$((logicalNumber / (physicalNumber * coreNumber)))

echo "****** CPU Information ******"
echo "Logical CPU Number  : ${logicalNumber}"
echo "Physical CPU Number : ${physicalNumber}"
echo "CPU Core Number     : ${coreNumber}"
echo "HT Number           : ${HTNumber}"

echo "*****************************"

15.程序运行时间的计算:
15.1 在QT中,用QTime,精度毫秒

QTime time; 
time.start(); 

function();

cout<< "Use time:" << time.elapsed()/1000.0 << "s" << endl;  

15.2 gettimeofday()精度微秒

#include <sys/time.h>  

    struct timeval tpstart,tpend;  
    float timeuse;  

    gettimeofday(&tpstart,NULL);  
    function();  
    gettimeofday(&tpend,NULL);  
    timeuse=(1000000*(tpend.tv_sec-tpstart.tv_sec) + tpend.tv_usec-tpstart.tv_usec)/1000000.0; 
    cout << "Use time:" << timeuse << endl; 

15.3 clock(),精度为ms级

#include <sys/time.h>  

    double time_Start = (double)clock();  
    function();  
    double time_End = (double)clock();

16.inf,nan:
inf一般是因为得到的数值,超出浮点数的表示范围(溢出,即阶码部分超过其能表示的最大值);而nan一般是因为对浮点数进行了未定义的操作,如对-1开方。

#include<math.h>

1int fpclassify(x)  //用来查看浮点数x的情况,fpclassify可以用任何浮点数表达式作为参数,fpclassify的返回值有以下几种情况。
                  //FP_NAN:x是一个“not a number”。
                  //FP_INFINITE: x是正、负无穷。
                  //FP_ZERO: x是0。
                  //FP_SUBNORMAL: x太小,以至于不能用浮点数的规格化形式表示。
                  //FP_NORMAL: x是一个正常的浮点数(不是以上结果中的任何一种)。

2int isfinite(x)  //当(fpclassify(x)!=FP_NAN&&fpclassify(x)!=FP_INFINITE)时,此宏得到一个非零值。
3int isnormal(x)  //当(fpclassify(x)==FP_NORMAL)时,此宏得到一个非零值。
4int isnan(x)   //当(fpclassify(x)==FP_NAN)时,此宏返回一个非零值。
5int isinf(x)   //当x是正无穷是返回1,当x是负无穷时返回-1。(有些较早的编译器版本中,无论是正无穷还是负无穷,都返回非零值,不区分正负无穷)。

17. ubuntu find 命令

find ~/dataset/PedestrainDataset/NICTAPedestrians/ -name \*.pnm  > test.txt
生成一个包含数据路径和名字的txt文件

18. cmake install 路径

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../../installDir ..

19. ubuntu 磁盘空间查看

sudo baobab

20. ubuntu开机启动脚本

1.新建个脚本文件new_service.sh

#!/bin/bash
# command content

exit 0

2.给权限,再放到/etc/init.d/目录下

sudo chmod 777 new_service.sh
sudo mv new_service.sh /etc/init.d/

3.将脚本添加到启动脚本

cd /etc/init.d/
sudo update-rc.d new_service.sh defaults 99 //执行如下指令,在这里90表明一个优先级,越高表示执行的越晚

4.移除Ubuntu开机脚本

sudo update-rc.d -f new_service.sh remove

21. tar打包

.tar.tgz 
解压:tar zxvf FileName.tar.tgz 
压缩:tar zcvf FileName.tar.tgz FileName 

22. C/C++ 文件目录创建删除操作

// 创建目录
int CreatDir(string dir)
{
    const int dir_err = mkdir(dir.c_str() , S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
    if (-1 == dir_err)
    {
        printf("Error creating directory!n");
        return 0;
    }
    return 1;
}

// 删除某个文件
remove(char * filename);

// 递归删除目录
参考 http://blog.youkuaiyun.com/honty/article/details/7822923

23. 用cv::glob获取文件夹下某个后缀格式的所有绝对路径

//获取后缀名为.jpg的所有文件的绝对路径并存储到image_files里
std::string pattern_jpg =  "../data/*.jpg";
std::vector<cv::String> image_files;
cv::glob(pattern_jpg, image_files);

24. Ubuntu 查找文件夹中内容包含关键字的文件

http://blog.youkuaiyun.com/lizhenmingdirk/article/details/44834997

25. CMakeLists中用pkg找库

## 首先设置所需要的.pc文件所在目录
set( ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:your_file_path/pkgconfig" )

## 以protobuf为例
find_package(PkgConfig)
pkg_check_modules(Protobuf protobuf)
include_directories(${Protobuf_INCLUDE_DIRS})
link_directories(${Protobuf_LIBRARY_DIRS})

26. 谷歌浏览器Your connection is not private

$ sudo apt-get install libnss3-1d

即可。

27. typora 闪退 relocation error: /usr/share/typora/resources/app/node_modules/spellchecker/build/Release/spellcheck

$ sudo apt install nodejs-legacy
$ sudo apt install npm
$ npm install spellchecker
$ sudo cp node_modules/spellchecker/build/Release/spellchecker.node  /usr/share/typora/resources/app/node_modules/spellchecker/build/Release/

28. home主文件夹侧边快捷方式

$ gedit ~/.config/user-dirs.dirs

29. json_parser_read.hpp:257:264: error: ‘type name’ declared as function returning an array escape

http://blog.youkuaiyun.com/allyli0022/article/details/62881238

30. C++ 读取一个文件夹下所有文件名

http://blog.youkuaiyun.com/MLlearnerTJ/article/details/78202457

31. linux下的FTP Client

http://blog.youkuaiyun.com/swartz_lubel/article/details/57115820

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值