[关闭]
@cyysu 2018-08-10T01:20:57.000000Z 字数 13821 阅读 1763

嵌入式ARM-VIM移植教程

  • 时间:2017年11月15日16:17:45
  • 作者:Kali
  • 邮箱:cyysu.github.io@gmail.com/2869905223@qq.com/微信lwyx1413
  • 版本:4.0
  • 描述:嵌入式ARM上移植vim

Linux字符界面系列教程


移植过程

  1. VIM这个编译工具也是依赖于ncurses,所以在编译vim之前首先要编译ncurses,这个在我们移植htop的时候就已经编译过了,我这里就不在演示编译过程了。只需要做一下下面这个链接就可以了。如果有小伙伴不知道怎么编译的可以查看下面这篇教程。
  2. 进入lib目录,创建littinfo的符号链接
  3. cd lib
  4. ln -s libncurses.so.5 libtinfo.so.5
  5. ln -s libtinfo.so.5 libtinfo.so

嵌入式ARM-htop移植教程

下面我们直接编译vim

  1. root@DZ:~# cd /home/mj/htop_arm/vim74/
  2. root@DZ:/home/mj/htop_arm/vim74# ./configure --prefix=/home/mj/install_vim --with-features=tiny --disable-gui --without-x --disable-selinux --disable-acl --disable-gpm CPPFLAGS=-I/home/mj/install_ncurses/include/ncurses LDFLAGS=-L/home/mj/install_ncurses/lib
  3. configure: creating cache auto/config.cache
  4. checking whether make sets $(MAKE)... yes
  5. checking for gcc... gcc
  6. checking whether the C compiler works... yes
  7. checking for C compiler default output file name... a.out
  8. checking for suffix of executables...
  9. checking whether we are cross compiling... no
  10. checking for suffix of object files... o
  11. checking whether we are using the GNU C compiler... yes
  12. checking whether gcc accepts -g... yes
  13. checking for gcc option to accept ISO C89... none needed
  14. checking how to run the C preprocessor... gcc -E
  15. checking for grep that handles long lines and -e... /bin/grep
  16. checking for egrep... /bin/grep -E
  17. checking for library containing strerror... none required
  18. checking for gawk... gawk
  19. checking for strip... strip
  20. checking for ANSI C header files... yes
  21. checking for sys/wait.h that is POSIX.1 compatible... yes
  22. checking --enable-fail-if-missing argument... no
  23. configure: checking for buggy tools...
  24. checking for BeOS... no
  25. checking for QNX... no
  26. checking for Darwin (Mac OS X)... no
  27. checking --with-local-dir argument... Defaulting to /usr/local
  28. checking --with-vim-name argument... Defaulting to vim
  29. checking --with-ex-name argument... Defaulting to ex
  30. checking --with-view-name argument... Defaulting to view
  31. checking --with-global-runtime argument... no
  32. checking --with-modified-by argument... no
  33. checking if character set is EBCDIC... no
  34. checking --disable-selinux argument... yes
  35. checking --with-features argument... tiny
  36. checking --with-compiledby argument... no
  37. checking --disable-xsmp argument... no
  38. checking --disable-xsmp-interact argument... no
  39. checking --enable-luainterp argument... no
  40. checking --enable-mzschemeinterp argument... no
  41. checking --enable-perlinterp argument... no
  42. checking --enable-pythoninterp argument... no
  43. checking --enable-python3interp argument... no
  44. checking --enable-tclinterp argument... no
  45. checking --enable-rubyinterp argument... no
  46. checking --enable-cscope argument... no
  47. checking --enable-workshop argument... no
  48. checking --disable-netbeans argument... no
  49. checking for socket in -lsocket... no
  50. checking for gethostbyname in -lnsl... yes
  51. checking whether compiling netbeans integration is possible... yes
  52. checking --enable-sniff argument... no
  53. checking --enable-multibyte argument... no
  54. checking --enable-hangulinput argument... no
  55. checking --enable-xim argument... defaulting to auto
  56. checking --enable-fontset argument... no
  57. defaulting to: don't HAVE_X11
  58. checking --enable-gui argument... no GUI support
  59. checking X11/SM/SMlib.h usability... yes
  60. checking X11/SM/SMlib.h presence... yes
  61. checking for X11/SM/SMlib.h... yes
  62. checking for CYGWIN environment... no
  63. checking whether toupper is broken... no
  64. checking whether __DATE__ and __TIME__ work... yes
  65. checking whether __attribute__((unused)) is allowed... yes
  66. checking elf.h usability... yes
  67. checking elf.h presence... yes
  68. checking for elf.h... yes
  69. checking for main in -lelf... no
  70. checking for dirent.h that defines DIR... yes
  71. checking for library containing opendir... none required
  72. checking stdarg.h usability... yes
  73. checking stdarg.h presence... yes
  74. checking for stdarg.h... yes
  75. checking stdint.h usability... yes
  76. checking stdint.h presence... yes
  77. checking for stdint.h... yes
  78. checking stdlib.h usability... yes
  79. checking stdlib.h presence... yes
  80. checking for stdlib.h... yes
  81. checking string.h usability... yes
  82. checking string.h presence... yes
  83. checking for string.h... yes
  84. checking sys/select.h usability... yes
  85. checking sys/select.h presence... yes
  86. checking for sys/select.h... yes
  87. checking sys/utsname.h usability... yes
  88. checking sys/utsname.h presence... yes
  89. checking for sys/utsname.h... yes
  90. checking termcap.h usability... yes
  91. checking termcap.h presence... yes
  92. checking for termcap.h... yes
  93. checking fcntl.h usability... yes
  94. checking fcntl.h presence... yes
  95. checking for fcntl.h... yes
  96. checking sgtty.h usability... yes
  97. checking sgtty.h presence... yes
  98. checking for sgtty.h... yes
  99. checking sys/ioctl.h usability... yes
  100. checking sys/ioctl.h presence... yes
  101. checking for sys/ioctl.h... yes
  102. checking sys/time.h usability... yes
  103. checking sys/time.h presence... yes
  104. checking for sys/time.h... yes
  105. checking sys/types.h usability... yes
  106. checking sys/types.h presence... yes
  107. checking for sys/types.h... yes
  108. checking termio.h usability... yes
  109. checking termio.h presence... yes
  110. checking for termio.h... yes
  111. checking iconv.h usability... yes
  112. checking iconv.h presence... yes
  113. checking for iconv.h... yes
  114. checking inttypes.h usability... yes
  115. checking inttypes.h presence... yes
  116. checking for inttypes.h... yes
  117. checking langinfo.h usability... yes
  118. checking langinfo.h presence... yes
  119. checking for langinfo.h... yes
  120. checking math.h usability... yes
  121. checking math.h presence... yes
  122. checking for math.h... yes
  123. checking unistd.h usability... yes
  124. checking unistd.h presence... yes
  125. checking for unistd.h... yes
  126. checking stropts.h usability... yes
  127. checking stropts.h presence... yes
  128. checking for stropts.h... yes
  129. checking errno.h usability... yes
  130. checking errno.h presence... yes
  131. checking for errno.h... yes
  132. checking sys/resource.h usability... yes
  133. checking sys/resource.h presence... yes
  134. checking for sys/resource.h... yes
  135. checking sys/systeminfo.h usability... no
  136. checking sys/systeminfo.h presence... no
  137. checking for sys/systeminfo.h... no
  138. checking locale.h usability... yes
  139. checking locale.h presence... yes
  140. checking for locale.h... yes
  141. checking sys/stream.h usability... no
  142. checking sys/stream.h presence... no
  143. checking for sys/stream.h... no
  144. checking termios.h usability... yes
  145. checking termios.h presence... yes
  146. checking for termios.h... yes
  147. checking libc.h usability... no
  148. checking libc.h presence... no
  149. checking for libc.h... no
  150. checking sys/statfs.h usability... yes
  151. checking sys/statfs.h presence... yes
  152. checking for sys/statfs.h... yes
  153. checking poll.h usability... yes
  154. checking poll.h presence... yes
  155. checking for poll.h... yes
  156. checking sys/poll.h usability... yes
  157. checking sys/poll.h presence... yes
  158. checking for sys/poll.h... yes
  159. checking pwd.h usability... yes
  160. checking pwd.h presence... yes
  161. checking for pwd.h... yes
  162. checking utime.h usability... yes
  163. checking utime.h presence... yes
  164. checking for utime.h... yes
  165. checking sys/param.h usability... yes
  166. checking sys/param.h presence... yes
  167. checking for sys/param.h... yes
  168. checking libintl.h usability... yes
  169. checking libintl.h presence... yes
  170. checking for libintl.h... yes
  171. checking libgen.h usability... yes
  172. checking libgen.h presence... yes
  173. checking for libgen.h... yes
  174. checking util/debug.h usability... no
  175. checking util/debug.h presence... no
  176. checking for util/debug.h... no
  177. checking util/msg18n.h usability... no
  178. checking util/msg18n.h presence... no
  179. checking for util/msg18n.h... no
  180. checking frame.h usability... no
  181. checking frame.h presence... no
  182. checking for frame.h... no
  183. checking sys/acl.h usability... no
  184. checking sys/acl.h presence... no
  185. checking for sys/acl.h... no
  186. checking sys/access.h usability... no
  187. checking sys/access.h presence... no
  188. checking for sys/access.h... no
  189. checking sys/sysinfo.h usability... yes
  190. checking sys/sysinfo.h presence... yes
  191. checking for sys/sysinfo.h... yes
  192. checking wchar.h usability... yes
  193. checking wchar.h presence... yes
  194. checking for wchar.h... yes
  195. checking wctype.h usability... yes
  196. checking wctype.h presence... yes
  197. checking for wctype.h... yes
  198. checking for sys/ptem.h... no
  199. checking for sys/sysctl.h... yes
  200. checking for pthread_np.h... no
  201. checking strings.h usability... yes
  202. checking strings.h presence... yes
  203. checking for strings.h... yes
  204. checking if strings.h can be included after string.h... yes
  205. checking whether gcc needs -traditional... no
  206. checking for an ANSI C-conforming const... yes
  207. checking for working volatile... yes
  208. checking for mode_t... yes
  209. checking for off_t... yes
  210. checking for pid_t... yes
  211. checking for size_t... yes
  212. checking for uid_t in sys/types.h... yes
  213. checking for uint32_t... yes
  214. checking whether time.h and sys/time.h may both be included... yes
  215. checking for ino_t... yes
  216. checking for dev_t... yes
  217. checking whether byte ordering is bigendian... no
  218. checking for rlim_t... yes
  219. checking for stack_t... yes
  220. checking whether stack_t has an ss_base field... no
  221. checking --with-tlib argument... empty: automatic terminal library selection
  222. checking for tgetent in -ltinfo... yes
  223. checking whether we talk terminfo... yes
  224. checking what tgetent() returns for an unknown terminal... zero
  225. checking whether termcap.h contains ospeed... yes
  226. checking whether termcap.h contains UP, BC and PC... yes
  227. checking whether tputs() uses outfuntype... no
  228. checking whether sys/select.h and sys/time.h may both be included... yes
  229. checking for /dev/ptc... no
  230. checking for SVR4 ptys... yes
  231. checking for ptyranges... don't know
  232. checking default tty permissions/group... can't determine - assume ptys are world accessible
  233. world
  234. checking return type of signal handlers... void
  235. checking for struct sigcontext... yes
  236. checking getcwd implementation is broken... no
  237. checking for bcmp... yes
  238. checking for fchdir... yes
  239. checking for fchown... yes
  240. checking for fsync... yes
  241. checking for getcwd... yes
  242. checking for getpseudotty... no
  243. checking for getpwent... yes
  244. checking for getpwnam... yes
  245. checking for getpwuid... yes
  246. checking for getrlimit... yes
  247. checking for gettimeofday... yes
  248. checking for getwd... yes
  249. checking for lstat... yes
  250. checking for memcmp... yes
  251. checking for memset... yes
  252. checking for mkdtemp... yes
  253. checking for nanosleep... yes
  254. checking for opendir... yes
  255. checking for putenv... yes
  256. checking for qsort... yes
  257. checking for readlink... yes
  258. checking for select... yes
  259. checking for setenv... yes
  260. checking for setpgid... yes
  261. checking for setsid... yes
  262. checking for sigaltstack... yes
  263. checking for sigstack... yes
  264. checking for sigset... yes
  265. checking for sigsetjmp... no
  266. checking for sigaction... yes
  267. checking for sigvec... no
  268. checking for strcasecmp... yes
  269. checking for strerror... yes
  270. checking for strftime... yes
  271. checking for stricmp... no
  272. checking for strncasecmp... yes
  273. checking for strnicmp... no
  274. checking for strpbrk... yes
  275. checking for strtol... yes
  276. checking for tgetent... yes
  277. checking for towlower... yes
  278. checking for towupper... yes
  279. checking for iswupper... yes
  280. checking for usleep... yes
  281. checking for utime... yes
  282. checking for utimes... yes
  283. checking for _LARGEFILE_SOURCE value needed for large files... no
  284. checking for special C compiler options needed for large files... no
  285. checking for _FILE_OFFSET_BITS value needed for large files... no
  286. checking for st_blksize... yes
  287. checking whether stat() ignores a trailing slash... no
  288. checking for iconv_open()... yes
  289. checking for nl_langinfo(CODESET)... yes
  290. checking for strtod in -lm... yes
  291. checking for strtod() and other floating point functions... yes
  292. checking --disable-acl argument... yes
  293. checking --disable-gpm argument... yes
  294. checking --disable-sysmouse argument... no
  295. checking for sysmouse... no
  296. checking for FD_CLOEXEC... yes
  297. checking for rename... yes
  298. checking for sysctl... not usable
  299. checking for sysinfo... yes
  300. checking for sysinfo.mem_unit... yes
  301. checking for sysconf... yes
  302. checking size of int... 4
  303. checking size of long... 8
  304. checking size of time_t... 8
  305. checking size of off_t... 8
  306. checking uint32_t is 32 bits... ok
  307. checking whether memmove handles overlaps... yes
  308. checking for _xpg4_setrunelocale in -lxpg4... no
  309. checking how to create tags... ctags -I INIT+ --fields=+S
  310. checking how to run man with a section nr... man -s
  311. checking --disable-nls argument... no
  312. checking for msgfmt... msgfmt
  313. checking for NLS... gettext() works
  314. checking for bind_textdomain_codeset... yes
  315. checking for _nl_msg_cat_cntr... yes
  316. checking dlfcn.h usability... yes
  317. checking dlfcn.h presence... yes
  318. checking for dlfcn.h... yes
  319. checking for dlopen()... no
  320. checking for dlopen() in -ldl... yes
  321. checking for dlsym()... yes
  322. checking setjmp.h usability... yes
  323. checking setjmp.h presence... yes
  324. checking for setjmp.h... yes
  325. checking for GCC 3 or later... yes
  326. checking whether we need -D_FORTIFY_SOURCE=1... yes
  327. checking linker --as-needed support... yes
  328. configure: updating cache auto/config.cache
  329. configure: creating auto/config.status
  330. config.status: creating auto/config.mk
  331. config.status: creating auto/config.h
  332. # 开始执行编译
  333. root@DZ:/home/mj/htop_arm/vim74# make CC=arm-none-linux-gnueabi-gcc
  334. ...
  335. ...
  336. OLD_PO_FILE_INPUT=yes msgfmt -v -o ru.mo ru.po
  337. 1869 条已翻译消息.
  338. OLD_PO_FILE_INPUT=yes msgfmt -v -o sk.mo sk.po
  339. 1628 条已翻译消息.
  340. OLD_PO_FILE_INPUT=yes msgfmt -v -o sv.mo sv.po
  341. 1697 条已翻译消息.
  342. OLD_PO_FILE_INPUT=yes msgfmt -v -o uk.mo uk.po
  343. 1819 条已翻译消息.
  344. OLD_PO_FILE_INPUT=yes msgfmt -v -o vi.mo vi.po
  345. 1422 条已翻译消息.
  346. OLD_PO_FILE_INPUT=yes msgfmt -v -o zh_CN.UTF-8.mo zh_CN.UTF-8.po
  347. 1634 条已翻译消息,3 条模糊消息.
  348. OLD_PO_FILE_INPUT=yes msgfmt -v -o zh_CN.mo zh_CN.po
  349. 1633 条已翻译消息,3 条模糊消息.
  350. OLD_PO_FILE_INPUT=yes msgfmt -v -o zh_TW.UTF-8.mo zh_TW.UTF-8.po
  351. 1422 条已翻译消息.
  352. OLD_PO_FILE_INPUT=yes msgfmt -v -o zh_TW.mo zh_TW.po
  353. 1422 条已翻译消息.
  354. OLD_PO_FILE_INPUT=yes msgfmt -v -o cs.cp1250.mo cs.cp1250.po
  355. 1284 条已翻译消息.
  356. OLD_PO_FILE_INPUT=yes msgfmt -v -o ja.sjis.mo ja.sjis.po
  357. 1869 条已翻译消息.
  358. OLD_PO_FILE_INPUT=yes msgfmt -v -o ja.euc-jp.mo ja.euc-jp.po
  359. 1869 条已翻译消息.
  360. OLD_PO_FILE_INPUT=yes msgfmt -v -o pl.cp1250.mo pl.cp1250.po
  361. 1869 条已翻译消息.
  362. OLD_PO_FILE_INPUT=yes msgfmt -v -o pl.UTF-8.mo pl.UTF-8.po
  363. 1869 条已翻译消息.
  364. OLD_PO_FILE_INPUT=yes msgfmt -v -o ru.cp1251.mo ru.cp1251.po
  365. 1869 条已翻译消息.
  366. OLD_PO_FILE_INPUT=yes msgfmt -v -o sk.cp1250.mo sk.cp1250.po
  367. 1628 条已翻译消息.
  368. OLD_PO_FILE_INPUT=yes msgfmt -v -o uk.cp1251.mo uk.cp1251.po
  369. 1819 条已翻译消息.
  370. OLD_PO_FILE_INPUT=yes msgfmt -v -o zh_CN.cp936.mo zh_CN.cp936.po
  371. 1633 条已翻译消息,3 条模糊消息.
  372. make[2]: Leaving directory '/home/mj/htop_arm/vim74/src/po'
  373. make[2]: Entering directory '/home/mj/htop_arm/vim74/src/po'
  374. make[2]: Nothing to be done for 'converted'.
  375. make[2]: Leaving directory '/home/mj/htop_arm/vim74/src/po'
  376. make[1]: Leaving directory '/home/mj/htop_arm/vim74/src'
  377. # 移植成功标志
  378. root@DZ:/home/mj/htop_arm/vim74/src# file vim
  379. vim: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.3, for GNU/Linux 2.6.16, not stripped

开发板验证

  1. # 将移植到开发板的ncurses的库也做上如下的链接
  2. ln -s libncurses.so.5 libtinfo.so.5
  3. ln -s libtinfo.so.5 libtinfo.so
  4. root@DZ:/home/mj/htop_arm/vim74/src# scp vim root@master:/tmp
  5. root@master's password:
  6. vim 100% 1911KB 1.9MB/s 00:00
  7. # 嵌入式ARM端
  8. [root@3352-T tmp]# ls
  9. dbus/ libform.so* libmenu.so* libncurses.so* libpanel.so* libtinfo.so.5@
  10. htop* libform.so.5* libmenu.so.5* libncurses.so.5* libpanel.so.5* resolv.conf
  11. libcurses.a libform.so.5.9* libmenu.so.5.9* libncurses.so.5.9* libpanel.so.5.9* terminfo/
  12. libcurses.so* libform_g.a libmenu_g.a libncurses_g.a libpanel_g.a umconfig.txt
  13. libform.a libmenu.a libncurses.a libpanel.a libtinfo.so@ vim*
  14. # 运行效果见下图

错误解析

  1. make CC=arm-linux-gnueabihf-gcc
  2. term.c:33:23: fatal error: termcap.h: 没有那个文件或目录
  3. compilation terminated.
  4. Makefile:2724: recipe for target 'objects/term.o' failed
  5. make: *** [objects/term.o] Error 1
  6. 若出现上面的错误是因为vim依赖库libtinfolibtinfo而已经包含在libncurses的库里面了,所以要先交叉编译ncurses

VIM源码文件

结束语

  1. 以上内容有笔者自己编写,也有摘自互联网。摘自互联网部分笔者都会仔细阅读,确保符合笔者当时测试情况进行编写,当然在学习的过程中不可避免的有理解不到位的地方,还请读友批评指正。

打赏

                    支付宝                                                         微信

微信与支付宝支付

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注