title: Eclipse error: "make: *** No rule to make target `all'. Stop."
body: <h1>Background for the question</h1>
  
  <p>When I studied CS in the university, we had to build a CBIR project with C (and we got C++ file that does all the "hard work" of image processing). </p>
  
  <p>Now I'm trying to create this project in Java. </p>
  
  <p>I didn't know how to implement in Java some of the things in that C++ file, so I decided to use JNI and call that file from my Java program. </p>
  
  <p>I'm using this tutorial for JNI:
  <a href="https://www3.ntu.edu.sg/home/ehchua/programming/java/JavaNativeInterface.html#zz-2.6" rel="nofollow noreferrer">https://www3.ntu.edu.sg/home/ehchua/programming/java/JavaNativeInterface.html#zz-2.6</a></p>
  
  <h2>Development Environment</h2>
  
  <p>+Eclipse IDE for Java Developers (32 bit),  Version: 2018-09 (4.9.0).</p>
  
  <p>+CDT plugin for Eclipse</p>
  
  <p>+Windows 10 64 bit (I use eclipse 32-bit because at some point, the 64-bit eclipse couldn't open and the solution was to use 32-bit eclipse)</p>
  
  <h1>The problem</h1>
  
  <p>When I do this part of the tutorial:</p>
  
  <blockquote>
    <p>Right-click on the "makefile" ⇒ Make Targets ⇒ Create ⇒ In "Target Name", >enter "all". Repeat to create a target "clean".</p>
    
    <p>Run the makefile for the target "all", by right-click on the makefile ⇒ Make >Targets ⇒ Build ⇒ Select the target "all" ⇒ Build</p>
  </blockquote>
  
  <p>It seems like it's working well.</p>
  
  <p>But when I run the program (as was advised in "Step 5: Run the Java JNI Program"), although the program prints to the console what I wanted,after it finished running, Eclipse show me:</p>
  
  <pre><code>Unresolved inclusion: &lt;jni.h&gt;
  </code></pre>
  
  <p>in both the c++ file and the header file. </p>
  
  <p>And I checked and I do have jni.h file in the path that I wrote in the makefile ("C:\Program Files (x86)\Java\jdk1.8.0_212\include").</p>
  
  <p>Also, I would like to know how to compile after my next changes to the cpp/h files.</p>
  
  <h1>Edit:</h1>
  
  <p>Now I noticed that before running the program, there is a Warning in the "Problems" tab:</p>
  
  <blockquote>
    <p>Invalid project path: Include path not found (Program Files >(x86)\Java\jdk1.8.0_212\include).</p>
  </blockquote>
  
  <p>But I don't understand why it's written as "Program Files" instead of "C\Program Files".</p>
  
  <h1>Edit2:</h1>
  
  <p>I created a new project in the hope that it will solve the problem.
  When I did "build" to the target "all", I got the error:</p>
  
  <pre><code>make: *** No rule to make target `all'.  Stop.
  </code></pre>
  
  <p>I saw that someone suggested to check "Generate Makefiles automatically" (In Project properties -> C/C++ Build) but when I did it, I saw on the console "nothing to build for project CBIR2"</p>
  
  <p>So I did again "build" to the target "all" and in some "magical" way, that error disappeared.</p>
  
  <p>Then it seemed like the run is ok (even though the running time is very long) , but when I checked the "Problems" tab, I saw again the error:</p>
  
  <pre><code>make: *** No rule to make target `all'.  Stop.
  </code></pre>
  
  <p>So I did again "build" to the target "all" and that error disappeared . </p>
  
  <p>But obviously something is wrong here if I get that error every time that I run the program, and also before the first time that I run the program.</p>
  
  <h1>makefile</h1>
  
  <pre><code># Define a variable for classpath
  CLASS_PATH = ../bin
  
  # Define a virtual path for .class in the bin directory
  vpath %.class $(CLASS_PATH)
  
  all : SPImageProc.dll
  
  # $@ matches the target, $&lt; matches the first dependency
  SPImageProc.dll : SPImageProc.o
      gcc -Wl,--add-stdcall-alias -shared -o $@ $&lt;
  
  # $@ matches the target, $&lt; matches the first dependency
  SPImageProc.o : SPImageProc.cpp SPImageProc.h
      gcc -I"C:\Program Files (x86)\Java\jdk1.8.0_212\include" -I"C:\Program Files (x86)\Java\jdk1.8.0_212\include\win32" -c $&lt; -o $@
  
  # $* matches the target filename without the extension
  SPImageProc.h : SPImageProc.class
      javah -classpath $(CLASS_PATH) $*
  
  clean :
      rm SPImageProc.h SPImageProc.o SPImageProc.dll
  </code></pre>
  
  <h1>SPImageProc.cpp</h1>
  
  <pre><code>#include &lt;jni.h&gt;
  #include &lt;stdio.h&gt;
  #include "SPImageProc.h"
  
  JNIEXPORT void JNICALL Java_SPImageProc_saySPImageProc(JNIEnv *env, jobject thisObj) {
     printf("SPImageProc 333!\n");
     return;
  }
  </code></pre>
  
  <h1>SPImageProc.h</h1>
  
  <pre><code>/* DO NOT EDIT THIS FILE - it is machine generated */
  #include &lt;jni.h&gt;
  /* Header for class SPImageProc */
  
  #ifndef _Included_SPImageProc
  #define _Included_SPImageProc
  #ifdef __cplusplus
  extern "C" {
  #endif
  /*
   * Class:     SPImageProc
   * Method:    saySPImageProc
   * Signature: ()V
   */
  JNIEXPORT void JNICALL Java_SPImageProc_saySPImageProc
    (JNIEnv *, jobject);
  
  #ifdef __cplusplus
  }
  #endif
  #endif
  </code></pre>
  
  <h1>CBIR.java</h1>
  
  <pre><code>public class CBIR {
  
  
  
  
     public static void main(String[] args) {
  
        SPImageProc.example();
     }
  }
  </code></pre>
  
  <h1>SPImageProc.java</h1>
  
  <pre><code>
  public class SPImageProc {
  
      static {
          System.loadLibrary("SPImageProc"); // SPImageProc.dll
      }
  
  
      // Declare native method
      private native void saySPImageProc();
  
  
  
      public static void example() {
  
  
          // Allocate an instance and invoke the native method
          new SPImageProc().saySPImageProc();  
      }
  }
  
  </code></pre>