是在windows里面實(shí)現(xiàn)用gcc/g++編譯調(diào)試c/cpp文件:
1,首先下載安裝MinGW,下載地址在http:///projects/mingw/。這個(gè)是邊下載邊安裝的,下載完成即安裝完成。我的安裝目錄是G:\MinGW。 2,設(shè)置環(huán)境變量。右擊我的電腦,點(diǎn)屬性->高級(jí)->環(huán)境變量。然后: 1、在PATH里加入G:\MinGW\bin,記得,如果里面還有其他的變量,記得要加個(gè)分號(hào)啊,分號(hào)得在英文輸入模式下輸入的。 具體路徑請(qǐng)根據(jù)你的MinGW選擇。 3,在你的_vimrc文件中配置編譯調(diào)試選項(xiàng)。我的個(gè)人配置如下: “定義CompileRun函數(shù),用來調(diào)用進(jìn)行編譯和運(yùn)行 func CompileRun()
exec “w”
“C程序
if &filetype == ‘c’
exec “!gcc -Wall -enable-auto-import % -g -o %<.exe”
“c++程序
elseif &filetype == ‘cpp’
exec “!g++ -Wall -enable-auto-import % -g -o %<.exe”
“Java程序
elseif &filetype == ‘java’
exec “!javac %”
endif
endfunc
“結(jié)束定義CompileRun
“定義Run函數(shù)
func Run()
if &filetype == ‘c’ || &filetype == ‘cpp’
exec “!%<.exe”
elseif &filetype == ‘java’
exec “!java %<”
endif
endfunc
“定義Debug函數(shù),用來調(diào)試程序
func Debug()
exec “w”
“C程序
if &filetype == ‘c’
exec “!gcc % -g -o %<.exe”
exec “!gdb %<.exe”
elseif &filetype == ‘cpp’
exec “!g++ % -g -o %<.exe”
exec “!gdb %<.exe”
“Java程序
elseif &filetype == ‘java’
exec “!javac %”
exec “!jdb %<”
endif
endfunc
“結(jié)束定義Debug
“設(shè)置程序的運(yùn)行和調(diào)試的快捷鍵F5和Ctrl-F5
map <F5> :call CompileRun()<CR>
map <F6> :call Run()<CR>
map <C-F5> :call Debug()<CR>
4,完成上面幾步基本上就大功告成啦,盡情享受vim編程吧。 可能遇到的問題: 編譯的時(shí)候可能會(huì)出現(xiàn): Info: resolving std::cout by linking to __imp___ZSt4cout (auto-import) c:/mingw/bin/../lib/gcc/mingw32/4.5.0/../../../../mingw32/bin/ld.exe: warning: a uto-importing has been activated without –enable-auto-import specified on the c ommand line. This should work unless it involves constant data structures referencing symbols from auto-imported DLLs.) 在編譯命令中加入 -enable-auto-import 就行啦 |
|