windows 为什么 Git Bash 不能运行我的可执行文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29805173/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 19:02:10  来源:igfitidea点击:

Why can't Git Bash run my executable?

windowsgitbashmingw-w64msys2

提问by pedroos

I am on git-for-windowsGit Bash. I can't run an executable on the command line:

我在git-for-windowsGit Bash 上。我无法在命令行上运行可执行文件:

Pedr@Abc-07 MINGW64 /c/dev
$ ls sqlite3.exe
sqlite3.exe*

Pedr@Abc-07 MINGW64 /c/dev
$ sqlite3
bash: sqlite3: command not found

Why is it so?

为什么会这样?

回答by Nattgew

To run a program in the current directory in bash, you put ./in front of it. So in your case:

要在 bash 中运行当前目录中的程序,你把./它放在它前面。所以在你的情况下:

$ ./sqlite3.exe

When you run sqlite3, bash will look for a program with exactly that name in all directories of the PATHenvironment variable, which by default includes standard locations for executables like /usr/local/binbut not your current directory. See herefor more info on that.

当您运行 时sqlite3,bash 将在PATH环境变量的所有目录中查找具有该名称的程序,默认情况下,该目录包括可执行文件的标准位置,例如/usr/local/bin但不包括您的当前目录。有关更多信息,请参见此处

回答by Alvarova

It's because you're under a is a runtime environment for gcc, that give you support to binaries native under Windows, but you can run any exe as shell using ./ (local execute) Take a look to documentation of this tool: http://sourceforge.net/p/mingw-w64/wiki2/FAQ/

这是因为您在 gcc 的运行时环境下,它为您提供对 Windows 下本机二进制文件的支持,但您可以使用 ./(本地执行)将任何 exe 作为 shell 运行,请查看此工具的文档:http: //sourceforge.net/p/mingw-w64/wiki2/FAQ/