I am trying to include spi.h header file in JNI C code, when the /usr/include/at-spi-1.0/cspi/spi.h file is included in c code I got the following fatal error like " fatal error: cspi/spi.h: No such file or directory ".
我试图在JNI C代码中包含spi.h头文件,当c /代码中包含/usr/include/at-spi-1.0/cspi/spi.h文件时,我得到了以下致命错误,如“致命错误: cspi / spi.h:没有这样的文件或目录“。
for creating '.so' file i used following command like:
用于创建'.so'文件我使用以下命令:
sudo gcc -shared -fPIC -o libHelloJNI.so -I/usr/lib/jvm/java-7-openjdk-amd64/include -I/usr/lib/jvm/java-7-openjdk-amd64/include/linux -I/usr/include/at-spi-1.0/cspi HelloJNI.c
using '-I' I included JNI.h header file successful but when I am trying to include the /usr/include/at-spi-1.0/cspi/spi.h, file I got the fatal error that No such file or directory.
使用'-I'我包含JNI.h头文件成功但当我试图包含/usr/include/at-spi-1.0/cspi/spi.h时,文件我得到致命错误,没有这样的文件或目录。
so please look at following code and give your feedback please!
所以请查看以下代码并提供反馈!
#include<jni.h>
#include<cspi/spi.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include"HelloJNI.h"
// Implementation of native method sayHello() of HelloJNI class
JNIEXPORT void JNICALL Java_HelloJNI_sayHello(JNIEnv *env,
jobject thisObj,jint a)
{
printf("Hello World! %d\n",a);
return;
}
JNIEXPORT void JNICALL JAVA_HelloJNI_initSPI(JNIEnv *env, jclass
cls)
{
int init_error;
init_error = SPI_init();
putenv("GTK_MODULES=gail:atk-bridge");
putenv("GNOME_ACCESSIBILITY=1");
if(init_error)
{
printf("First time error %d in Initialising
SPI\n",init_error);
}
else
{
printf("SPI Initialise successfully");
}
SPI_event_main();
return;
}
1 个解决方案
#1
0
If you specify cspi/spi.h
in the #include
directive, you don't need cspi
in the -I
switch.
如果在#include指令中指定cspi / spi.h,则在-I开关中不需要cspi。
Change it to:
将其更改为:
-I/usr/include/at-spi-1.0/
#1
0
If you specify cspi/spi.h
in the #include
directive, you don't need cspi
in the -I
switch.
如果在#include指令中指定cspi / spi.h,则在-I开关中不需要cspi。
Change it to:
将其更改为:
-I/usr/include/at-spi-1.0/