简体   繁体   中英

Eclipse CDT — program “make” cannot be found (win7, mingw, msys installed)

I'm running Eclipse Juno with CDT on Windows 7. Have installed MinGW with msys and set up my PATH. If I just run cmd.exe and type make , it runs the msys make.exe :

C:\Users\dev>make
make: *** No targets specified and no makefile found.  Stop.

C:\Users\dev>echo %PATH%
C:\Program Files (x86)\Windows Resource Kits\Tools\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\MySQL\MySQL Server 5.5\bin;C:\Program Files (x86)\php;C:\Program Files (x86)\libtidy\bin;C:\Program Files\7-Zip;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Java\jdk1.7.0\bin;C:\Program Files (x86)\apache-ant-1.8.4\bin;C:\Program Files\TortoiseHg\;C:\Program Files (x86)\Windows Resource Kits\Tools\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\MySQL\MySQL Server 5.5\bin;C:\Program Files (x86)\php;C:\Program Files (x86)\libtidy\bin;C:\Program Files\7-Zip;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Java\jdk1.7.0\bin;C:\Program Files (x86)\apache-ant-1.8.4\bin;C:\Program Files\TortoiseHg\;C:\Program Files (x86)\MinGW\bin;C:\Program Files (x86)\MinGW\msys\1.0\bin

So far so good. But even after restarting Eclipse (even rebooting Windows!), CDT gives me the following error message when I try to make the simple "Hello World" C program:

Program "make" not found in PATH

Eclipse错误输出

The funny thing is, if I run the following Java code from Eclipse...

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Temp {
    public static void main(String[] args) {
        System.out.println(System.getenv("PATH"));
        try {
            String line;
            Process p = Runtime.getRuntime().exec("make");
            BufferedReader input =
              new BufferedReader
                (new InputStreamReader(p.getErrorStream()));
            while ((line = input.readLine()) != null) {
                System.out.println(line);
            }
            input.close();
          }
          catch (Exception err) {
            err.printStackTrace();
          }
    }
}

...I get exactly the output I would expect, namely:

C:\Program Files (x86)\Windows Resource Kits\Tools\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\MySQL\MySQL Server 5.5\bin;C:\Program Files (x86)\php;C:\Program Files (x86)\libtidy\bin;C:\Program Files\7-Zip;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Java\jdk1.7.0\bin;C:\Program Files (x86)\apache-ant-1.8.4\bin;C:\Program Files\TortoiseHg\;C:\Program Files (x86)\MinGW\bin;C:\Program Files (x86)\MinGW\msys\1.0\bin
make: *** No targets specified and no makefile found.  Stop.

Why can't Eclipse CDT find make when everybody else can!?

无论出于何种原因,将MinGW和Msys路径移动到PATH变量的前面(它们在上面的问题的末尾)解决了我的问题。

Also after adding C:\\MinGW\\bin to PATH variable. Make sure your new project is created with MinGW GCC toolchain as shown below.

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM