compile error while using dlopen

Hi unix lovers,

I am getting error while compile a function which uses dlopen.

My code is

I am getting error as follows

Am I missing something? I think I am missing a lot :slight_smile:

I am using solaris.

Thanks in advance,
-Ashish

I have made few changes in test program. Added errorno and dlerror() just for error checking

when I compile the program I get error

any pointers why the linking error?

-Ashish

Then you must link it explicitly with dl, try

 cc -o testjvm2 testjvm2.c -ldl

Thanks a lot andryk. It worked on solaris.

I tried the same program on hp-ux.
On hp-ux it fails to load jvm library.

Any pointers why it is failing on hp-ux?

-Ashish

hi ,
In Hp-Ux , when creating a shred lib we have to use +z option to create an object file for shared lib ,
for ex:
$cc +z -c share.c -o share.o

$ld -b share.o -o share.sl ( to create a shared lib )

Just try this and let me know !

Thanks
Narendra

Hi Narenadra,
I am not creating shared library. I am just opening it in my program with statement
retval = (int)dlopen("libjvm.sl",RTLD_LAZY);

-Ashish