JNI库加载错误

时间:2014-07-12 09:50:39

标签: java c++ linux gcc java-native-interface

我正在尝试编译一个调用c ++函数的java类。我正在使用Ubuntu和gcc编译器。  以下是文件:---->

JAVA CLASS

public class JNIVips {
 static {
  System.loadLibrary("JNIVips"); // JNIVips.dll (Windows) or libJNIVips.so (Unixes)   }

   // Native method declaration
  private native void callMain(String[] argv);

  // Test Driver
   public static void main(String[] args) {
  new JNIVips().callMain(args);  // Invoke native method
 }
}

C ++文件看起来像这样===>

#include "JNIVipsImpl.h"
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vips/vips>
#include <vips/vips.h>

void callMain (char **argv)
{.........}

JNIVipsCpp.c

#include <jni.h>
#include "JNIVipsImpl.h"
#include "JNIVips.h"


JNIEXPORT void JNICALL Java_JNIVips_callMain(JNIEnv *env, jobject thisObj, jobjectArray argv )
{
    return callMain();
}

JNIVipsImpl.h ==&GT;

#ifndef _JNI_VIPS_IMPL_H
#define _JNI_VIPS_IMPL_H
#ifdef __cplusplus
    extern "C" {
 #endif

    void callMain();

  #ifdef __cplusplus
    }
  #endif 

  #endif

我在终端中使用以下命令来编译代码。一个接一个。

1)javac JNIVips.java

2)javah JNIVips

3)g++ -c -I"/usr/local/java/jdk1.7.0_60/include" -I"/usr/local/java/jdk1.7.0_60/include /linux" -Wall JNIVipsImpl.cc 'pkg-config vipsCC --cflags --libs'

4)g++ -shared -fPIC -I"/usr/local/java/jdk1.7.0_60/include" -I"/usr/local/java/jdk1.7.0_60/include/linux" -o libJNIVips.so -shared -Wl,-soname,libJNIVips.so 'pkg-config vipsCC --cflags --libs'

我收到以下错误

 Error: Could not find or load main class JNIVips]

0 个答案:

没有答案
相关问题