“致命错误:特征/密集:没有这样的文件或目录”//特征库

时间:2015-03-11 11:14:04

标签: android c++ eclipse android-ndk java-native-interface

我在Windows 8.1上使用Java-Eclipse Luna进行Android编程,我也在使用本机环境(C ++)。我试图在我的本机代码中使用Eigen库。我得到一个"致命错误:Eigen / Dense:没有这样的文件或目录"错误,我不知道背后的原因。这是我的代码:

我的.java文件:

package com.example.androideignv2;

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

public class AndroidEignV2Activity extends ActionBarActivity {

/** Loading the Native library */
static {
    /** Use either of the following two methods to load the native library*/
    System.loadLibrary("myNativeLibrary");
    //System.load("/data/data/cookbook.chapter2/lib/libNativeRegister.so");
}

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_android_eign_v2);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.android_eign_v2, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    if (id == R.id.action_settings) {
        return true;
    }
    return super.onOptionsItemSelected(item);
}
}

我的.cpp原生库:

#include <jni.h>
#include <android/log.h>
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <Eigen/Dense>


using namespace Eigen;
using namespace std;

int main() // int argc, char* argv[]
{
  MatrixXd m = MatrixXd::Random(3,3);
  m = (m + MatrixXd::Constant(3,3,1.2)) * 50;
  cout << "m =" << endl << m << endl;
  VectorXd v(3);
  v << 1, 2, 3;
  //cout << "m * v =" << endl << m * v << endl;
}

我的Android.mk文件:

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := myNativeLibrary
LOCAL_SRC_FILES := myNativeLibrary.cpp
LOCAL_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)

我的Application.mk文件:

APP_ABI := all
APP_STL:=stlport_static 

我将Eigen库文件夹包含在&#34; Paths and Symbols&#34;通过做: Project / Properties / C / C ++ General / Paths and Symbols / includes /然后我浏览了我的Eigen库路径。

任何提示都将深受赞赏

1 个答案:

答案 0 :(得分:1)

您只在Eclipse路径和符号中添加了Eigen库include文件夹。

从实际的NDK构建中引用此库是您必须执行的另一个步骤。你的图书馆是如何组织的?它已经为Android编译了吗?

您可以从 Android.mk 中引用第三方预建的NDK库。如果您拥有的是静态预构建库而不是共享库,则将.soSHARED的出现替换为.aSTATIC

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := eigen
LOCAL_SRC_FILES := /path/to/eigen/prebuilts/$(TARGET_ARCH_ABI)/libeigen.so
LOCAL_EXPORT_C_INCLUDES := /absolute/path/to/includes
include $(PREBUILT_SHARED_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := myNativeLibrary
LOCAL_SRC_FILES := myNativeLibrary.cpp
LOCAL_SHARED_LIBRARIES := eigen
LOCAL_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)