2013-09-16 54 views
0

我有這個CPP文件:頭:沒有這樣的文件或目錄

//pkgnative_tries__native_NativeSystem.cpp 
#include <pkgnative_tries__native_NativeSystem.h> 
#include<iostream> 
using namespace std; 

extern "C" 
JNIEXPORT void JNICALL Java_ClassName_MethodName 
    (JNIEnv *env, jobject obj, jstring javaString) 
{ 
    //Get the native string from javaString 
    const char *nativeString = env->GetStringUTFChars(javaString, 0); 
    cout << nativeString; 

    env->ReleaseStringUTFChars(javaString, nativeString); 
} 

pkgnative_tries__native_NativeSystem.h:

/* DO NOT EDIT THIS FILE - it is machine generated */ 
#include <jni.h> 
/* Header for class pkgnative_tries__native_NativeSystem */ 

#ifndef _Included_pkgnative_tries__native_NativeSystem 
#define _Included_pkgnative_tries__native_NativeSystem 
#ifdef __cplusplus 
extern "C" { 
#endif 
/* 
* Class:  pkgnative_tries__native_NativeSystem 
* Method: println 
* Signature: (Ljava/lang/String;)V 
*/ 
JNIEXPORT void JNICALL Java_pkgnative_tries__1native_NativeSystem_println 
    (JNIEnv *, jobject, jstring); 

#ifdef __cplusplus 
} 
#endif 
#endif 

的問題是,當我嘗試它g++編譯成一個DLL,它說:

g++ -c -DBUILDING_EXAMPLE_DLL pkgnative_tries__native_NativeSystem.cpp 

pkgnative_tries__native_NativeSystem.cpp:1:50: fatal error: pkgnative_tries__native_NativeSystem.h: No such file or directory 
compilation terminated 

有誰知道爲什麼?我敢肯定,這兩個文件是在同一目錄

+3

嘗試'#include「pkgnative_tries__native_NativeSystem.h」' – Beta

+0

請參閱:http://stackoverflow.com/questions/21593/what-is-the-difference-between-include-filename-and-include-filename – phonetagger

+0

@ Beta工作,謝謝! – BackSlash

回答

6

當您使用尖括號中包括(例如#include <xyz>),它不會在目錄中查找從其中包括完成。改用雙引號,例如#include "xyz"

相關問題