0

Ok..

I have a problem of reading .so file via .a and my main application.

my main console application includes .a static library file, and a function in .a static library file reads .so file using dlopen() function.

My .so project is shared object that calls java source code using JNI. it compiles well and generate .so file.

My .a project is to read .so file using the function, dlopen(). it compiles well and generates .a file.

However, it got stopped at dlopen() function. it gets no pointer to my .so file. when I see my error using dlerror(), it says:

"fail to dlopen, libjvm.so: cannot open shared object file: No such file or directory"

I set LD_LIBRARY_PATH correctly, and I think that is why my .so project implementing JNI got compiled very well: I included correct include and library path of JDK for this .so project.

I am on Ubuntu 64bit and working on all console, .a, .so projects (total 3 project) using Netbeans IDE.

But interestingly, if I try to load that .so file in a just simple c program, it reads very well.

I do not know why following independent simple c program can read my .so file but my main project's console application cannot read via .a file.

here is source code of that simple c program:

#include <stdio.h>
#include <dlfcn.h>


int main(int argc, char **argv)
{
    void *handle = NULL;
    int (*result)(int, int);

    handle = dlopen("/home/online0227/desktop/runDynamic/myso.so", RTLD_LAZY);
    if ( !handle )
    { 
        printf("fail to dlopen, %s\n", dlerror());
        return 0;
    } else {
printf("succeeded1111\n");
}


    dlclose(handle);
    return 0;
}

Here is what I typed to compile and run this simple C program:

gcc -o main main.c -ldl
./main
4

2 回答 2

0

你的问题不是myso.so- 仔细阅读。只需检查 PATH 是否包含正确的路径引用libjvm.so(java 所在的位置)

于 2013-08-26T17:03:16.767 回答
0

只是在黑暗中拍摄:libjvm.so 可能依赖于另一个无法找到/打开的 .so 文件。

尝试运行:

ldd libjvm.so
于 2013-08-26T19:24:28.150 回答