So I am using the gvim editor to program in C++, however when I open a .cpp
file on the editor then type :!g++ -std=C++17 file.cpp -o file
I get this error:
See attached file below:
C:\Windows\system32\cmd.exe /c(g++ -std=c++17 file.cpp - o file)
g++: error: file.cpp: No such file or directory
g++: fatal error: no input files
compilation terminated
现在这与vim或我的命令有关吗?
提前致谢。
It seems that you're unfortunately using gcc-mingw that doesn't come with gnumake properly configured (
:let $CXXFLAGS='-std=c++17 -Wall -Werror'
+make %<
would have been enough otherwise). Thus you'll have a do a few things manually. And don't misspell the parameters to g++. And forget:!{compilername}
, this is want we had to do 25 years ago with vi. Unlike vi, vim permits to integrate compilation.->
:h quickfix
This shouldn't execute g++ from the wrong directory. If this still does, run
:cd %:h
.The execution should work with
:./%
.如果您希望为此使用热键...
Automatically opening the quickfix windows only if there are errors or executing the result only if there are no errors requires a little more work.