The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
C compile error kuampang High Level Programming 3 11-30-2006 12:30 AM
compile error message putput High Level Programming 4 10-04-2006 04:43 AM
Compile error coulio High Level Programming 9 06-30-2006 05:43 AM
resolve_symbols: loader error: dlopen: gfhgfnhhn High Level Programming 1 06-29-2006 10:08 AM
Error in compile C by gcc zico High Level Programming 4 11-12-2003 02:45 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-15-2006
shriashishpatil shriashishpatil is offline
Registered User
  
 

Join Date: Dec 2005
Location: Pune
Posts: 81
compile error while using dlopen

Hi unix lovers,

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

My code is
Quote:
$ cat testjvm.c
#include<stdio.h>
#include <dlfcn.h>
#include <link.h>


void main()
{

int retval=0;
retval = (int)dlopen("libjvm.so",RTLD_LAZY);
if(retval == 0)
printf("\nFailed to load JVM Library");
else
printf("\nSuccessfully loaded JVM Library");

}
I am getting error as follows
Quote:
$ cc testjvm.c
Undefined first referenced
symbol in file
dlopen testjvm1.o (symbol belongs to implicit dependency /usr/lib/libdl.so.1)
ld: fatal: Symbol referencing errors. No output written to a.out
$
Am I missing something? I think I am missing a lot :-)

I am using solaris.

Thanks in advance,
-Ashish
  #2 (permalink)  
Old 03-16-2006
shriashishpatil shriashishpatil is offline
Registered User
  
 

Join Date: Dec 2005
Location: Pune
Posts: 81
I have made few changes in test program. Added errorno and dlerror() just for error checking
Quote:
$
$ cat testjvm2.c
#include <stdio.h>
#include <errno.h>
#include <dlfcn.h>

void main(void)
{

void *handle;

handle = dlopen("libjvm.so", RTLD_LAZY);
if( handle == NULL )
{
printf("errno[%d], errmsg[%s]\n", errno, dlerror());
return;
}
else
{
printf("\nJVM loaded successfully");
}
dlclose(handle);

}
$


when I compile the program I get error

Quote:
$ cc -o testjvm2 testjvm2.c
Undefined first referenced
symbol in file
dlopen testjvm2.o (symbol belongs to implicit dependency /usr/lib/libdl.so.1)
dlclose testjvm2.o (symbol belongs to implicit dependency /usr/lib/libdl.so.1)
dlerror testjvm2.o (symbol belongs to implicit dependency /usr/lib/libdl.so.1)
ld: fatal: Symbol referencing errors. No output written to testjvm2
$
Quote:
$ uname -a
SunOS snvi003 5.8 Generic_117350-20 sun4u sparc SUNW,Sun-Fire-V240
$

any pointers why the linking error?

-Ashish
  #3 (permalink)  
Old 03-16-2006
andryk's Avatar
andryk andryk is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2003
Posts: 448
Quote:
Undefined first referenced
symbol in file
dlopen testjvm2.o (symbol belongs to implicit dependency /usr/lib/libdl.so.1)
dlclose testjvm2.o (symbol belongs to implicit dependency /usr/lib/libdl.so.1)
dlerror testjvm2.o (symbol belongs to implicit dependency /usr/lib/libdl.so.1)
ld: fatal: Symbol referencing errors. No output written to testjvm2
Then you must link it explicitly with dl, try
Code:
 cc -o testjvm2 testjvm2.c -ldl
  #4 (permalink)  
Old 03-16-2006
shriashishpatil shriashishpatil is offline
Registered User
  
 

Join Date: Dec 2005
Location: Pune
Posts: 81
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.
Quote:
$
$ cc -o testjvm testjvm.c
$
$ testjvm
errno[0], errmsg[Can't open shared library: libjvm.sl]
$
$ echo $SHLIB_PATH
/opt/weblogic810sp3/jdk142_03/jre/lib/PA_RISC/server:/crmusr1.pi004/users/cluser/ruchit/clarify/orion01/ClarifyCRMApplications/bin:.:/oravl01/oracle/9.2.0.5/lib32:/usr/lib:/opt/tuxedo/lib:/opt/weblogic810sp3/jdk142_03/jre/lib
$
$ echo $LD_LIBRARY_PATH
/opt/weblogic810sp3/jdk142_03/jre/lib/PA_RISC/server:/crmusr1.pi004/users/cluser/ruchit/clarify/orion01/ClarifyCRMApplications/bin:.:/oravl01/oracle/9.2.0.5/lib32:/usr/lib:/opt/tuxedo/lib:/opt/weblogic810sp3/jdk142_03/jre/lib
$
$ uname -a
HP-UX hppi004 B.11.11 U 9000/800 1834916430 unlimited-user license
$
Any pointers why it is failing on hp-ux?


-Ashish
  #5 (permalink)  
Old 06-29-2006
naren_chella naren_chella is offline
Registered User
  
 

Join Date: Mar 2006
Posts: 36
Use +z option

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
  #6 (permalink)  
Old 06-29-2006
shriashishpatil shriashishpatil is offline
Registered User
  
 

Join Date: Dec 2005
Location: Pune
Posts: 81
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
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:10 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0