Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7033411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:03:46+00:00 2026-05-28T01:03:46+00:00

I try to develop an Android app. I already managed to implement a rather

  • 0

I try to develop an Android app. I already managed to implement a rather small c++ function using NDK. But now I want to use a pretty large c++ library which I found on Google Docs.
When I now try to build it with ndk-build tool, I get this error in cygwin console:

Compile++ thumb  : ndkfoo <= subspace.cpp
Compile++ thumb  : ndkfoo <= classifier.cpp
Compile++ thumb  : ndkfoo <= eigen.cpp
Compile++ thumb  : ndkfoo <= image.cpp
Compile++ thumb  : ndkfoo <= imageio.cpp
Compile++ thumb  : ndkfoo <= local.cpp
Compile++ thumb  : ndkfoo <= matrix.cpp
Compile++ thumb  : ndkfoo <= sample.cpp
SharedLibrary  : libndkfoo.so
./obj/local/armeabi/objs/ndkfoo/eigen.o: In function `LibSubspace::geneigen(doub
le*, double*, int, double*, int, bool)':
U:\workspace\test/jni/eigen.cpp:91: undefined reference to `ilaenv_'
U:\workspace\test/jni/eigen.cpp:96: undefined reference to `dsygv_'
U:\workspace\test/jni/eigen.cpp:128: undefined reference to `dggev_'
./obj/local/armeabi/objs/ndkfoo/eigen.o: In function `LibSubspace::eigen(double*
, double*, double*, int, bool)':
U:\workspace\test/jni/eigen.cpp:55: undefined reference to `ilaenv_'
U:\workspace\test/jni/eigen.cpp:58: undefined reference to `dsyev_'
collect2: ld returned 1 exit status
make: *** [obj/local/armeabi/libndkfoo.so] Error 1

The Code of this function is as follow:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <float.h>
#include <assert.h>
#include <string.h>

#include "eigen.h"

extern "C" int ilaenv_(int *ispec, const char *name__, const char *opts,
    int *n1, int *n2, int *n3, int *n4, int name_len, int opts_len);

extern "C" int dsyev_(const char *jobz, const char *uplo, int *n, double *a,
    int *lda, double *w, double *work, int *lwork, 
    int *info);

extern "C" int dsygv_(int *itype, const char *jobz, const char *uplo, int *
    n, double *a, int *lda, double *b, int *ldb, 
    double *w, double *work, int *lwork, int *info);

extern "C" int dggev_(const char *jobvl, const char *jobvr, int *n, double *
    a, int *lda, double *b, int *ldb, double *alphar, 
    double *alphai, double *beta, double *vl, int *ldvl, 
    double *vr, int *ldvr, double *work, int *lwork, 
    int *info);

namespace LibSubspace {

int eigen(double* A, double* V, double* E, int n, bool verbose) {
    int info;
    int ispec = 1;
    int lwork;

    lwork = (ilaenv_(&ispec,"DSYEV","U",&n,&n,&n,&n,5,1)+2)*n;
    double *work = (double *)malloc(lwork*sizeof(double));
    memcpy(V,A,n*n*sizeof(double));
    dsyev_("V","U",&n,V,&n,E,work,&lwork,&info);
    free(work);

    //check the return value
    if(info!=0) {
        if(verbose) {
            printf("Error computing eigenvectors: ");
            if(info>0) {
                printf("Algorithm failed to converge\n");
            } else if(info<0) {
                printf("Illegal argument\n");
            } else {
                printf("Unknown error\n");
            }
        }
        return 0;
    }

    return 1;
}


int geneigen(double *A, double *B, int n, double *W, int algorithm,
             bool verbose) {
    //getting the optimal lwork
    int ispec = 1;
    int lwork;
    int info;

    switch(algorithm) {

        case EIGEN_CHOL: 
        {
            //computing eigenvectors
            lwork = (ilaenv_(&ispec,"DSYGV","U",&n,&n,&n,&n,5,1)+2)*n;
            double *work = (double *)malloc(lwork*sizeof(double));
            int problemType = 1;
            char job = 'V';
            char uplo = 'U';
            dsygv_(&problemType,&job,&uplo,&n,A,&n,B,&n,W,work,&lwork,&info);

            free(work);

            //check the return value
            if(info!=0) {
                if(verbose) {
                    printf("Error computing eigenvectors: ");
                    if(info>n) {
                        printf("Matrix B is not positive definite\n");
                    } else if(info<=n) {
                        printf("The problem failed to converge\n");
                    } else if(info<0) {
                        printf("Illegal argument\n");
                    } else {
                        printf("Unknown error\n");
                    }
                }
                return 0;
            }
        }
        break;

        case EIGEN_QZ:
        {
            //more general algorithm
            double *alphar = (double *)malloc(n*sizeof(double));
            double *alphai = (double *)malloc(n*sizeof(double));
            double *beta = (double *)malloc(n*sizeof(double));
            double *VR = (double *)malloc(n*n*sizeof(double));
            lwork = 8*n;
            double *work = (double *)malloc(lwork*sizeof(double));
            dggev_("N","V",&n,A,&n,B,&n,alphar,alphai,beta,
                                   NULL,&n,VR,&n,work,&lwork,&info);
            //eigenvalues
            for(long i=0;i<n;i++) {
                if(beta[i]!=0) {
                    W[i] = alphar[i]/beta[i];
                } else W[i] = 0;
            }
            //eigenvectors
            for(long i=0;i<n;i++) {
                for(long j=0;j<n;j++) {
                    A[i*n+j] = VR[i*n+j];
                }
            }
            free(alphar);
            free(alphai);
            free(beta);
            free(VR);   
            free(work);

            if(info!=0) {
                printf("Error computing eigenvectors: ");
                if(info<0) {
                    printf("Illegal argument\n");
                } else if(info<=n) {
                    printf("QZ iteration failed\n");
                } else {
                    printf("Unknown error\n");
                }
                return 0;
            }
        }
        break;

    }

    return 1;
}

} //namespace

Unfortunatly I absolutly DONT understand why these errors occur. I am not much familiar with C++, thats why I wanted to use NDK in the hope of not having to change anything of the existing library.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:03:46+00:00Added an answer on May 28, 2026 at 1:03 am

    Google tells me that these functions are from the runtime of Fortran-to-C compiler. So you need to either link against a library called libf2c, or find the sources and make them a part of the NDK project too. The latter sounds like a more promising approach – I don’t think a ready made NDK build exists.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I develop games for Android, but now I want to try the iOS platform.
i am try to develop a small application. Now should i organize my 3rd
I'm trying to develop an Android application but when I try to connect to
I try to develop my first Android app with Eclipse and the Android maven
I'm currently trying to develop an encryption app for Android using ECDH and BouncyCastle.
We are trying to develop an app for Android where you can play a
I am to develop an Android application that receives a message from server but
I try to develop a simple average function in Haskell. This seems to work:
I've started Android programming recently so bear with me :) I develop an app
Hi all I am trying to develop an android extension for air, but I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.