"fatal error: Eigen/Dense: No such file or directory" // 本征库

"fatal error: Eigen/Dense: No such file or directory" // Eigen Library

本文关键字:directory or file No fatal error Eigen Dense such      更新时间:2023-10-16

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

我的.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 

我通过以下方式将特征库文件夹包含在"路径和符号"中:项目/属性/C/C++ 常规/路径和符号/包含/然后我浏览到我的特征库路径。

任何提示都将深表赞赏

您只将 Eigen 库包含文件夹添加到 Eclipse 路径和符号中。

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

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

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)
相关文章: