1.在嵌入式ARM开发板上
其实好多系统和配置相关的信息都在proc这个目录下面,该目录下面可以查看cpu的型号 核心数,时间,字符驱动和块驱动等等
内核的版本是
root@nitrogen:/proc# uname -a
Linux nitrogen 3.14.52-134465-ge706857 #61 SMP PREEMPT Fri Jun 9 16:41:37 CST 2017 armv7l armv7l armv7l GNU/Linux
操作系统版本也就是ubuntu的版本是
root@nitrogen:/proc# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.4 LTS
Release: 14.04
Codename: trusty
GCC的版本是
root@nitrogen:/proc# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/arm-linux-gnueabihf/4.8/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.8.4-2ubuntu1~14.04.3' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap --disable-libitm --disable-libquadmath --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-armhf/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-armhf --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-armhf --with-arch-directory=arm --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --enable-multilib --disable-sjlj-exceptions --with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=hard --with-mode=thumb --disable-werror --enable-checking=release --build=arm-linux-gnueabihf --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf
Thread model: posix
gcc version 4.8.4 (Ubuntu/Linaro 4.8.4-2ubuntu1~14.04.3)
传入到kernel的参数是
root@nitrogen:/proc# cat cmdline
console=ttymxc0,115200 root=/dev/mmcblk3p2 rootwait rw rootwait rw video=mxcfb0:dev=lcd,1024x768M@60,if=RGB24,bpp=32 video=mxcfb1:dev=hdmi,1920x1080M@60,if=RGB24,bpp=32
相关的version的参数
root@nitrogen:/proc# cat version
Linux version 3.14.52-134465-ge706857 (ouyang@ouyang-norco) (gcc version 4.9.1 20140710 (prerelease) (crosstool-NG linaro-1.13.1-4.9-2014.07 - Linaro GCC 4.9-2014.07) ) #61 SMP PREEMPT Fri Jun 9 16:41:37 CST 2017
时钟驱动以及实时时间
root@nitrogen:/proc/driver# ls
rtc
root@nitrogen:/proc/driver# cat rtc
rtc_time : 01:46:54
rtc_date : 2017-06-23
24hr : yes
root@nitrogen:/proc/driver#
查看字符设备和块设备
root@nitrogen:/proc# cat devices
查看系统的位数(这里的ARM板子是32位滴)
root@nitrogen:/proc# getconf LONG_BIT
32
2./dev目录下面的相关信息
这些都是设备节点 能够直接使用
Fd = open () 来打开设备
2.开机启动配置 可以配置 /etc/rc.local 文件 以及配置fstab文件
*一般安装了某一个软件 但是又不知道其用法 可以使用
例如:./nxserver–help 来查看软件的用法
如果文件中描述的用法是
这些都是设备节点 能够直接使用
Fd
= open () 来打开设备
1.开机启动配置
可以配置 /etc/rc.local 文件
以及配置fstab文件
*一般安装了某一个软件 但是又不知道其用法 可以使用
例如:./nxserver –help
来查看软件的用法
如果文件中描述的用法是
--clusteradd [--interface ] [--netmask
]
style="mso-spacerun:'yes';font-family:Tahoma;mso-fareast-font-family:微软雅黑;mso-bidi-font-family:'Times
New
Roman';font-size:11.0000pt;">
class="MsoNormal">
style="mso-spacerun:'yes';font-family:微软雅黑;mso-ascii-font-family:Tahoma;mso-hansi-font-family:Tahoma;mso-bidi-font-family:'Times
New Roman';font-size:11.0000pt;">那么可以使用命令:
style="mso-spacerun:'yes';font-family:Tahoma;mso-fareast-font-family:微软雅黑;mso-bidi-font-family:'Times
New
Roman';font-size:11.0000pt;">
class="MsoNormal">
class="MsoNormal">
style="mso-spacerun:'yes';font-family:微软雅黑;mso-ascii-font-family:Tahoma;mso-hansi-font-family:Tahoma;mso-bidi-font-family:'Times
New Roman';font-size:11.0000pt;">
face="微软雅黑">进入到/usr/bin(
face="微软雅黑">这个文件夹里面的命令能直接执行
face="Tahoma">)
face="微软雅黑">文件夹中执行以下命令
style="mso-spacerun:'yes';font-family:Tahoma;mso-fareast-font-family:微软雅黑;mso-bidi-font-family:'Times
New
Roman';font-size:11.0000pt;">
class="MsoNormal">
style="mso-spacerun:'yes';font-family:Tahoma;mso-fareast-font-family:微软雅黑;mso-bidi-font-family:'Times
New Roman';font-size:11.0000pt;">ln -s
/cross_gcc/gcc-linaro-5.3.1-2016.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc
./arm-linux-gcc
style="mso-spacerun:'yes';font-family:Tahoma;mso-fareast-font-family:微软雅黑;mso-bidi-font-family:'Times
New
Roman';font-size:11.0000pt;">
class="MsoNormal">
style="mso-spacerun:'yes';font-family:微软雅黑;mso-ascii-font-family:Tahoma;mso-hansi-font-family:Tahoma;mso-bidi-font-family:'Times
New Roman';font-size:11.0000pt;">
face="微软雅黑">将会在此目录生成一个命令arm-linux-gcc
face="微软雅黑">这个命令能直接替代以前的较为长的
face="Tahoma">arm-linux-gnueabihf-gcc
face="微软雅黑">命令
style="mso-spacerun:'yes';font-family:Tahoma;mso-fareast-font-family:微软雅黑;mso-bidi-font-family:'Times
New
Roman';font-size:11.0000pt;">
class="MsoNormal">
style="mso-spacerun:'yes';font-family:微软雅黑;mso-ascii-font-family:Tahoma;mso-hansi-font-family:Tahoma;mso-bidi-font-family:'Times
New
Roman';font-size:11.0000pt;">可以查看该命令最终的指向:
style="mso-spacerun:'yes';font-family:Tahoma;mso-fareast-font-family:微软雅黑;mso-bidi-font-family:'Times
New
Roman';font-size:11.0000pt;">
class="MsoNormal">
src="file:///C:\Users\Lenovo\AppData\Local\Temp\ksohtml\wpsDCF7.tmp.jpg">
style="mso-spacerun:'yes';font-family:Tahoma;mso-fareast-font-family:微软雅黑;mso-bidi-font-family:'Times
New
Roman';font-size:11.0000pt;">
class="MsoNormal">
style="mso-spacerun:'yes';font-family:Tahoma;mso-fareast-font-family:微软雅黑;mso-bidi-font-family:'Times
New
Roman';font-size:11.0000pt;">
class="MsoNormal">
style="mso-spacerun:'yes';font-family:微软雅黑;mso-ascii-font-family:Tahoma;mso-hansi-font-family:Tahoma;mso-bidi-font-family:'Times
New Roman';font-size:11.0000pt;">分析以下代码
style="mso-spacerun:'yes';font-family:Tahoma;mso-fareast-font-family:微软雅黑;mso-bidi-font-family:'Times
New
Roman';font-size:11.0000pt;">
class="MsoNormal">
src="file:///C:\Users\Lenovo\AppData\Local\Temp\ksohtml\wpsDCF8.tmp.jpg">
style="mso-spacerun:'yes';font-family:Tahoma;mso-fareast-font-family:微软雅黑;mso-bidi-font-family:'Times
New
Roman';font-size:11.0000pt;">
class="MsoNormal">
style="mso-spacerun:'yes';font-family:微软雅黑;mso-ascii-font-family:Tahoma;mso-hansi-font-family:Tahoma;mso-bidi-font-family:'Times
New Roman';color:rgb(255,0,0);font-size:11.0000pt;">
face="微软雅黑">这个的意思是在生成可执行文件之前就已经执行了头文件的地址,和使用到的字体库,有的会执行动态库的地址
这些都是在生成可执行文件之前就包含进去的信息
所以需要将这些头文件
face="微软雅黑">和库放到相应的位置
face="微软雅黑">然后编译成功确保编译后的文件能够直接执
style="mso-spacerun:'yes';font-family:微软雅黑;mso-ascii-font-family:Tahoma;mso-hansi-font-family:Tahoma;mso-bidi-font-family:'Times
New Roman';font-size:11.0000pt;">行。
style="mso-spacerun:'yes';font-family:Tahoma;mso-fareast-font-family:微软雅黑;mso-bidi-font-family:'Times
New
Roman';font-size:11.0000pt;">
class="MsoNormal">
style="mso-spacerun:'yes';font-family:Tahoma;mso-fareast-font-family:微软雅黑;mso-bidi-font-family:'Times
New
Roman';font-size:11.0000pt;">
class="MsoNormal">
style="mso-spacerun:'yes';font-family:Tahoma;mso-fareast-font-family:微软雅黑;mso-bidi-font-family:'Times
New
Roman';font-size:11.0000pt;">
class="MsoNormal">
style="mso-spacerun:'yes';font-family:微软雅黑;mso-ascii-font-family:Tahoma;mso-hansi-font-family:Tahoma;mso-bidi-font-family:'Times
New Roman';font-size:11.0000pt;">我在编译的时候写入
style="mso-spacerun:'yes';font-family:Tahoma;mso-fareast-font-family:微软雅黑;mso-bidi-font-family:'Times
New Roman';font-size:11.0000pt;">gcc -o example1 example1.c
-I /usr/yl/include/freetype2 -lfreetype
–lm
style="mso-spacerun:'yes';font-family:Tahoma;mso-fareast-font-family:微软雅黑;mso-bidi-font-family:'Times
New
Roman';font-size:11.0000pt;">
class="MsoNormal">
style="mso-spacerun:'yes';font-family:微软雅黑;mso-ascii-font-family:Tahoma;mso-hansi-font-family:Tahoma;mso-bidi-font-family:'Times
New Roman';font-size:11.0000pt;">发生以下错误:
style="mso-spacerun:'yes';font-family:Tahoma;mso-fareast-font-family:微软雅黑;mso-bidi-font-family:'Times
New
Roman';font-size:11.0000pt;">
class="MsoNormal">
src="file:///C:\Users\Lenovo\AppData\Local\Temp\ksohtml\wpsDCF9.tmp.jpg">
style="mso-spacerun:'yes';font-family:Tahoma;mso-fareast-font-family:微软雅黑;mso-bidi-font-family:'Times
New
Roman';font-size:11.0000pt;">
class="MsoNormal">
style="mso-spacerun:'yes';font-family:微软雅黑;mso-ascii-font-family:Tahoma;mso-hansi-font-family:Tahoma;mso-bidi-font-family:'Times
New Roman';font-size:11.0000pt;">
face="微软雅黑">错误的根本原因是
face="微软雅黑">我们将freetype
face="微软雅黑">的库文件和头文件安装到了
face="Tahoma">/usr/yl这个位置
但是这个
style="mso-spacerun:'yes';font-family:Tahoma;mso-fareast-font-family:微软雅黑;mso-bidi-font-family:'Times
New Roman';font-size:11.0000pt;">–
style="mso-spacerun:'yes';font-family:微软雅黑;mso-ascii-font-family:Tahoma;mso-hansi-font-family:Tahoma;mso-bidi-font-family:'Times
New Roman';font-size:11.0000pt;">lfreetype
face="微软雅黑">根本就找不到这个lib
(libfreetype.so
face="微软雅黑">文件
face="Tahoma">)
style="mso-spacerun:'yes';font-family:Tahoma;mso-fareast-font-family:微软雅黑;mso-bidi-font-family:'Times
New
Roman';font-size:11.0000pt;">
class="MsoNormal">
style="mso-spacerun:'yes';font-family:微软雅黑;mso-ascii-font-family:Tahoma;mso-hansi-font-family:Tahoma;mso-bidi-font-family:'Times
New Roman';font-size:11.0000pt;">
face="微软雅黑">可用-L
face="微软雅黑">来指定这个库文件的目录, 并且再使用
face="Tahoma">-l
face="微软雅黑">来执行使用到这个目录中的具体的那个库
style="mso-spacerun:'yes';font-family:Tahoma;mso-fareast-font-family:微软雅黑;mso-bidi-font-family:'Times
New
Roman';font-size:11.0000pt;">
class="MsoNormal">
style="mso-spacerun:'yes';font-family:Tahoma;mso-fareast-font-family:微软雅黑;mso-bidi-font-family:'Times
New Roman';font-size:11.0000pt;">gcc -o example1 example1.c
-I/usr/yl/include/freetype2 -L/usr/yl/lib/
-lfreetype -lm
style="mso-spacerun:'yes';font-family:Tahoma;mso-fareast-font-family:微软雅黑;mso-bidi-font-family:'Times
New
Roman';font-size:11.0000pt;">
class="MsoNormal">
style="mso-spacerun:'yes';font-family:微软雅黑;mso-ascii-font-family:Tahoma;mso-hansi-font-family:Tahoma;mso-bidi-font-family:'Times
New Roman';color:rgb(255,0,0);font-size:11.0000pt;">
face="微软雅黑">其中
style="mso-spacerun:'yes';font-family:Tahoma;mso-fareast-font-family:微软雅黑;mso-bidi-font-family:'Times
New
Roman';color:rgb(255,0,0);font-size:11.0000pt;">–
style="mso-spacerun:'yes';font-family:微软雅黑;mso-ascii-font-family:Tahoma;mso-hansi-font-family:Tahoma;mso-bidi-font-family:'Times
New Roman';color:rgb(255,0,0);font-size:11.0000pt;">I
和
-L
后面的
face="Tahoma">/
face="微软雅黑">是没有空格的
style="mso-spacerun:'yes';font-family:Tahoma;mso-fareast-font-family:微软雅黑;mso-bidi-font-family:'Times
New
Roman';color:rgb(255,0,0);font-size:11.0000pt;">
class="MsoNormal">
style="mso-spacerun:'yes';font-family:Tahoma;mso-fareast-font-family:微软雅黑;mso-bidi-font-family:'Times
New
Roman';font-size:11.0000pt;">-I/usr/yl/include/freetype2
style="mso-spacerun:'yes';font-family:微软雅黑;mso-ascii-font-family:Tahoma;mso-hansi-font-family:Tahoma;mso-bidi-font-family:'Times
New Roman';font-size:11.0000pt;">
face="微软雅黑">是用来指定头文件地址的
style="mso-spacerun:'yes';font-family:Tahoma;mso-fareast-font-family:微软雅黑;mso-bidi-font-family:'Times
New
Roman';font-size:11.0000pt;">
class="MsoNormal">
style="mso-spacerun:'yes';font-family:Tahoma;mso-fareast-font-family:微软雅黑;mso-bidi-font-family:'Times
New
Roman';font-size:11.0000pt;">-L/usr/yl/lib/
style="mso-spacerun:'yes';font-family:微软雅黑;mso-ascii-font-family:Tahoma;mso-hansi-font-family:Tahoma;mso-bidi-font-family:'Times
New Roman';font-size:11.0000pt;">
face="微软雅黑">是用来指定库文件地址的
style="mso-spacerun:'yes';font-family:Tahoma;mso-fareast-font-family:微软雅黑;mso-bidi-font-family:'Times
New
Roman';font-size:11.0000pt;">
class="MsoNormal">
style="mso-spacerun:'yes';font-family:微软雅黑;mso-ascii-font-family:Tahoma;mso-hansi-font-family:Tahoma;mso-bidi-font-family:'Times
New Roman';font-size:11.0000pt;">-l/freetype
是要使用到的库,其全名定为
face="Tahoma">libfreetype.so
face="微软雅黑">文件
style="mso-spacerun:'yes';font-family:Tahoma;mso-fareast-font-family:微软雅黑;mso-bidi-font-family:'Times
New
Roman';color:rgb(255,0,0);font-size:11.0000pt;">
class="MsoNormal">
style="mso-spacerun:'yes';font-family:Tahoma;mso-fareast-font-family:微软雅黑;mso-bidi-font-family:'Times
New
Roman';color:rgb(255,0,0);font-size:11.0000pt;">
class="MsoNormal">
style="mso-spacerun:'yes';font-family:微软雅黑;mso-ascii-font-family:Tahoma;mso-hansi-font-family:Tahoma;mso-bidi-font-family:'Times
New Roman';font-size:11.0000pt;">
face="微软雅黑">如果不想这样每次编译的时候指定地址,
face="微软雅黑">可以将生成的库copy
face="微软雅黑">到
face="Tahoma">/usr/lib下面
或者在
face="Tahoma">/usr/lib
face="微软雅黑">下建立快捷方式文件
face="Tahoma">ln
style="mso-spacerun:'yes';font-family:Tahoma;mso-fareast-font-family:微软雅黑;mso-bidi-font-family:'Times
New Roman';font-size:11.0000pt;">–
style="mso-spacerun:'yes';font-family:微软雅黑;mso-ascii-font-family:Tahoma;mso-hansi-font-family:Tahoma;mso-bidi-font-family:'Times
New Roman';font-size:11.0000pt;">s 命令
style="mso-spacerun:'yes';font-family:Tahoma;mso-fareast-font-family:微软雅黑;mso-bidi-font-family:'Times
New
Roman';font-size:11.0000pt;">
class="MsoNormal">
style="mso-spacerun:'yes';font-family:微软雅黑;mso-ascii-font-family:Tahoma;mso-hansi-font-family:Tahoma;mso-bidi-font-family:'Times
New
Roman';font-size:11.0000pt;">建立之前我们需要查看一下
style="mso-spacerun:'yes';font-family:Tahoma;mso-fareast-font-family:微软雅黑;mso-bidi-font-family:'Times
New
Roman';font-size:11.0000pt;">
class="MsoNormal">
src="file:///C:\Users\Lenovo\AppData\Local\Temp\ksohtml\wpsDD09.tmp.jpg">
style="mso-spacerun:'yes';font-family:Tahoma;mso-fareast-font-family:微软雅黑;mso-bidi-font-family:'Times
New
Roman';font-size:11.0000pt;">
class="MsoNormal">
style="mso-spacerun:'yes';font-family:微软雅黑;mso-ascii-font-family:Tahoma;mso-hansi-font-family:Tahoma;mso-bidi-font-family:'Times
New Roman';font-size:11.0000pt;">
face="微软雅黑">这表明使用到的库
face="微软雅黑">本身是libfreetype.so ->
face="微软雅黑">到
face="Tahoma">libfreetype.so.6.9.0
style="mso-spacerun:'yes';font-family:Tahoma;mso-fareast-font-family:微软雅黑;mso-bidi-font-family:'Times
New
Roman';font-size:11.0000pt;">
class="MsoNormal">
style="mso-spacerun:'yes';font-family:微软雅黑;mso-ascii-font-family:Tahoma;mso-hansi-font-family:Tahoma;mso-bidi-font-family:'Times
New Roman';font-size:11.0000pt;">
face="微软雅黑">所以我们需要在/usr/lib
face="微软雅黑">文件夹下建立一个同样的软链接(快捷方式)
style="mso-spacerun:'yes';font-family:Tahoma;mso-fareast-font-family:微软雅黑;mso-bidi-font-family:'Times
New
Roman';font-size:11.0000pt;">
class="MsoNormal">
style="mso-spacerun:'yes';font-family:Tahoma;mso-fareast-font-family:微软雅黑;mso-bidi-font-family:'Times
New
Roman';font-size:11.0000pt;">
class="MsoNormal">
style="mso-spacerun:'yes';font-family:Tahoma;mso-fareast-font-family:微软雅黑;mso-bidi-font-family:'Times
New Roman';font-size:11.0000pt;">cd
/usr/lib
style="mso-spacerun:'yes';font-family:Tahoma;mso-fareast-font-family:微软雅黑;mso-bidi-font-family:'Times
New
Roman';font-size:11.0000pt;">