在Java/Python成为主流的今天,仍然用C/C++的古董程序员不多了,Code Blocks是开源跨平台C/C++ IDE,喜欢跨平台的C++多半只能选这个
上手第一件事情,添加vi插件
1、安装
http://www.codeblocks.org/downloads/binaries
由于cbvike用到了 wxmsw...库,而mingw安装包才提供了这个库,因此,需要安装mingw版本。
注意除了安装 codeblocks-20.03-mingw-setup.exe 之外,还需要下载源代码,后期要用。
http://www.codeblocks.org/downloads/source 源代码
2、下载vi插件cbvike
https://github.com/zmj64351508/cbvike
用cb打开vike.cbp
3、配置cb环境
配置编译环境,不能采用msys2的编译器目录,只能使用CodeBlocks自带的mingw的编译器目录:
配置3个全局CB变量:
cb_dll_path的base,设置为cb安装目录
cb_path的base,设置为下载的cb源代码目录
wx的base目录,设置为wxWidgets源码目录,注意lib要设置为自己编译的build里面的lib
4、build
注意编译如果出现如下错误:
cbvike.cpp|18|fatal error: codeblocks/editormanager.h: No such file or directory|
cbvike.h|7|fatal error: codeblocks/cbeditor.h: No such file or directory|
cbvike.h|7|fatal error: codeblocks/cbeditor.h: No such file or directory|
cbvike.h|7|fatal error: codeblocks/cbeditor.h: No such file or directory|
主要原因是codeblocks源码版本与这个插件当时的不同,这些.h文件都在,路径变化了,修改为正确目录即可,如:
//#include <codeblocks/editormanager.h>
#include <editormanager.h>
当提示 ld.exe||cannot find -lwxmsw28u| 的时候,需要修改build option
选中wxmsw28u,编辑 修改为 wxmsw313u_gcc_cb 这个文件在 codeblocks安装目录下,文件为:wxmsw313u_gcc_cb.dll
编译结果:
||=== Build: release in cbVike (compiler: GNU GCC Compiler) ===|
D:\cc\cbvike\vicmd.cpp|211|warning: no return statement in function returning non-void [-Wreturn-type]|
D:\cc\cbvike\vicmd.cpp|227|warning: no return statement in function returning non-void [-Wreturn-type]|
D:\cc\cbvike\vicmd.cpp|232|warning: no return statement in function returning non-void [-Wreturn-type]|
D:\cc\cbvike\vicmd.cpp|237|warning: no return statement in function returning non-void [-Wreturn-type]|
D:\cc\cbvike\vifunc.cpp||In member function 'int ViFunc::DummyOperatorCommand(VikeWin*, int, int, int, wxScintilla*)':|
D:\cc\cbvike\vifunc.cpp|265|warning: no return statement in function returning non-void [-Wreturn-type]|
D:\cc\cbvike\vifunc.cpp||In member function 'int ViFunc::DoDelete(VikeWin*, int, int, int, wxScintilla*)':|
D:\cc\cbvike\vifunc.cpp|306|warning: no return statement in function returning non-void [-Wreturn-type]|
D:\cc\cbvike\vifunc.cpp||In member function 'int ViFunc::DoChange(VikeWin*, int, int, int, wxScintilla*)':|
D:\cc\cbvike\vifunc.cpp|316|warning: no return statement in function returning non-void [-Wreturn-type]|
D:\cc\cbvike\vifunc.cpp||In member function 'int ViFunc::DoYank(VikeWin*, int, int, int, wxScintilla*)':|
D:\cc\cbvike\vifunc.cpp|353|warning: no return statement in function returning non-void [-Wreturn-type]|
||=== Build finished: 0 error(s), 8 warning(s) (0 minute(s), 8 second(s)) ===|
5、安装插件
plugins菜单,manage plugins,选择 install New按钮,选中cbvike目录下build目录生成的 cbVike.cbplugin
安装后,在插件列表中出现:
安装完成,打开任意源码文件,就进入到了vi编辑模式!!