g++ 致命错误没有这样的文件或目录
g++ fatal error no such file or directory
所以我使用 gvim editor 在 C++ 中编程,但是当我在编辑器上打开 .cpp
文件然后键入 :!g++ -std=C++17 file.cpp -o file
时,我收到此错误:
请参阅下面的附件:
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 或我的命令有关吗?
提前致谢。
很遗憾,您使用的 gcc-mingw 似乎没有正确配置 gnumake(:let $CXXFLAGS='-std=c++17 -Wall -Werror'
+ make %<
否则就足够了)。因此,您将需要手动执行一些操作。并且不要将参数拼错为 g++。忘了 :!{compilername}
,这是 25 年前我们必须用 vi 做的事情。与 vi 不同,vim 允许集成编译。
" to do once
:let &makeprg='g++ -std=c++17 -Wall -Werror % -o %<'
" to execute each time to compile
:make
:copen
" to navigate the errors
:cc " jump to error under cursor
:cnext " jump to next error
:cprev " jump to previous error
:cclose " close the quickfix window
-> :h quickfix
这不应该从错误的目录执行 g++。如果仍然如此,运行 :cd %:h
.
执行应该适用于 :./%
。
如果您希望为此设置热键...
nnoremap <silent> <F7> :<c-u>update<cr>:make<cr>
nnoremap <silent> <C-F5> :<c-u>./%<cr>
nnoremap <silent> <F3> :<c-u>cnext<cr>
nnoremap <silent> <S-F3> :<c-u>cprev<cr>
仅在出现错误时自动打开 quickfix windows 或仅在没有错误时才执行结果需要 .
所以我使用 gvim editor 在 C++ 中编程,但是当我在编辑器上打开 .cpp
文件然后键入 :!g++ -std=C++17 file.cpp -o file
时,我收到此错误:
请参阅下面的附件:
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 或我的命令有关吗?
提前致谢。
很遗憾,您使用的 gcc-mingw 似乎没有正确配置 gnumake(:let $CXXFLAGS='-std=c++17 -Wall -Werror'
+ make %<
否则就足够了)。因此,您将需要手动执行一些操作。并且不要将参数拼错为 g++。忘了 :!{compilername}
,这是 25 年前我们必须用 vi 做的事情。与 vi 不同,vim 允许集成编译。
" to do once
:let &makeprg='g++ -std=c++17 -Wall -Werror % -o %<'
" to execute each time to compile
:make
:copen
" to navigate the errors
:cc " jump to error under cursor
:cnext " jump to next error
:cprev " jump to previous error
:cclose " close the quickfix window
-> :h quickfix
这不应该从错误的目录执行 g++。如果仍然如此,运行 :cd %:h
.
执行应该适用于 :./%
。
如果您希望为此设置热键...
nnoremap <silent> <F7> :<c-u>update<cr>:make<cr>
nnoremap <silent> <C-F5> :<c-u>./%<cr>
nnoremap <silent> <F3> :<c-u>cnext<cr>
nnoremap <silent> <S-F3> :<c-u>cprev<cr>
仅在出现错误时自动打开 quickfix windows 或仅在没有错误时才执行结果需要