在vim中调用vc编译并执行c++
2010-12-18 17:45
295 查看
本文提供一种方法, 可以在vim中按F5键来让cl编译并执行当前正在编辑的c++代码. 这样在写一些简单的测试代码的时候, 只要用vim编辑一个文件就可以开始工作, 不需要打开vc创建一个工程了, 比较方便:
1. 首先需要创建一个批处理文件, 命名为compile_cpp.bat
根据自己vc安装的路径和版本不同, 需要修改vc_path.
[b]2. 将 compile_cpp.bat 所在目录添加到系统搜索路径中[/b]
[b]3. 修改vim的配置文件vimrc, 在其中添加:[/b]
[b]
[b]这样在vim中按下F5键就可以编译执行当前正在编辑的c++代码了.[/b]
[b]本文转自:[/b]http://orit7.blogbus.com/logs/59646465.html
在此向原作者致谢。这是我一直想要解决的问题。
1. 首先需要创建一个批处理文件, 命名为compile_cpp.bat
@echo off rem Author: orit rem Last-Modified: 2009-10-14 rem Created: 2009-10-14 rem Introduction: %1 - compiled file. set vc_path=c:/Program Files/Microsoft Visual Studio 9.0/VC/bin set output_file=_temp_output_.exe set compile_option=/w /Fe%output_file% echo ==================================================== echo Compile...... echo ==================================================== if exist %output_file% (del %output_file%) call "%vc_path%/vcvars32.bat" call "%vc_path%/cl.exe" %compile_option% %1 rem Clear screen if no ERROR. if exist %output_file% (cls) else (goto end) echo ==================================================== echo Output echo ==================================================== call %output_file% rem Clear temporary files. del %output_file% del *.obj :end
根据自己vc安装的路径和版本不同, 需要修改vc_path.
[b]2. 将 compile_cpp.bat 所在目录添加到系统搜索路径中[/b]
[b]3. 修改vim的配置文件vimrc, 在其中添加:[/b]
[b]
autocmd FileType cpp map <F5> <Esc>:w!<CR>:!compile_cpp.bat %<CR>[/b]
[b]这样在vim中按下F5键就可以编译执行当前正在编辑的c++代码了.[/b]
[b]本文转自:[/b]http://orit7.blogbus.com/logs/59646465.html
在此向原作者致谢。这是我一直想要解决的问题。
相关文章推荐
- 在vim中调用vc编译并执行c++
- Matlab与c++混合编程[四.通过VC调用Matlab编译产生的dll文件]
- linux的ubuntu上如何编译C和C++代码写的动态库,以及调用执行
- Ubuntu&红帽的vim通用配置(文件头+一键编译执行C/C++/Java单文件)
- [C/C++] VC2012编译的程序在WinXP下报告“指定的可执行文件不是有效的 Win32 应用程序”错误
- Ubuntu&红帽的vim通用配置(文件头+一键编译执行C/C++/Java单文件)
- 用python程序调用C/C++编译的可执行文件
- emacs中c++程序编译执行
- 为什么在C++里调用被C编译器编译的函数,要加extern "c"
- Mingw版QtCreator调用VS编译的C++库的方法
- 制作一个Flex AIR 程序调用 可执行程序(mxmlc.exe) 并且 生成.as文件并编译为.swf文件
- VC与JavaScript交互(三) ———— JS调用C++
- C++ 调用编译好的liblas库读写lidar数据
- C#调用C++编译生成的dll文件
- C++编译期间的虚函数调用机制 .
- C++的编译单元、可执行程序、内部连接与外部连接
- C++程序编译执行具体步骤及各大系统中的编译命令
- VC界面编程,添加控件后可编译但不执行(即,不弹出对话框)
- [心得] 用FlasCC编译c++代码为SWC执行效率测试
- C++执行外部程序(调用外部exe程序)