Sponsored Content
Top Forums Programming compile error while using dlopen Post 102135 by shriashishpatil on Thursday 16th of March 2006 12:22:54 AM
Old 03-16-2006
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
 

10 More Discussions You Might Find Interesting

1. Programming

Error in compile C by gcc

Hi all, I compile my c program and get following result hrnpfc01.c:1387: stray '\' in program hrnpfc01.c:1387: parse error before `,' hrnpfc01.c:1388: stray '\' in program hrnpfc01.c:1388: parse error before `,' hrnpfc01.c:1396: stray '\' in program hrnpfc01.c:1396: parse error before... (4 Replies)
Discussion started by: zico
4 Replies

2. Programming

resolve_symbols: loader error: dlopen:

when i try to run an executable i got the following error message: resolve_symbols: loader error: dlopen: what does this error mean and what should be done to avoid this? with regards (1 Reply)
Discussion started by: gfhgfnhhn
1 Replies

3. Programming

Compile error

Dear All I have a program writen in C and test in Unix. Now, I am try to run this program in windows 2000. I am receiving an error ]_getopt is not define. I will appreciate if any one can help explain to me why this problem is hapening and to slove this problem. Thank you (9 Replies)
Discussion started by: coulio
9 Replies

4. Programming

compile error message

i was trying to compile a c program and got the error below. i need help on how to resolve this $ make -ef putput `if ; then echo getinf.awk ; else echo getora.awk;fi` EI.sql `if ; then echo esql -static ; else echo esqlo8i;fi` -O -I. -c EI`if ; then echo .ec; else echo... (4 Replies)
Discussion started by: putput
4 Replies

5. Programming

C compile error

hello can anyone help? :confused: i make a C code in FreeBSD 5.4 and it succeed to run the program requires connection to mysql server when i try to compile it under solaris i get this error message ld: fatal: file ./lib/libmysqlclient.so: wrong ELF machine type: EM_386 why? and how to... (3 Replies)
Discussion started by: kuampang
3 Replies

6. Programming

dlopen help

//foo.c #include<stdio.h> int pen(int a) { printf("%d",a); } $cc -c foo.c $ls -shared -o libfoo.so foo.o ///////////now libfoo.so formed //i have already designed libfoo.so //main.c #include<stdio.h> #include <dlfcn.h> int main() { (2 Replies)
Discussion started by: lookforlohith
2 Replies

7. Solaris

Samba 3.5.4 compile error

Hello! I am trying install samba 3.5.4. and following this instruction from the source package. So, there are my steps: 1 cd ../samba-3.5.4/source3 2 ./configure (without any arguments) and when i run make it returns error .................................................... Compiling... (2 Replies)
Discussion started by: zhum
2 Replies

8. UNIX for Dummies Questions & Answers

Compiling gcc to compile make to compile yaboot

I have just installed OpenBSD on a 333MHz PPC iMac G3. It has a 6GB HDD that has been partitioned as 1GB MacOS 8.5.1, 3GB MacOS X 10.3.9, 2GB OpenBSD 4.8. I now need to install a bootloader so that my computer can recognize the OpenBSD partition at startup. I have been trying to install... (0 Replies)
Discussion started by: t04st3r
0 Replies

9. Ubuntu

Kernel compile error

Hi I'm compiling a real-time kernel in linux, but after I type make bzImage things end with this: (Things going well doing CC and things).... CC arch/x86/kernel/kgdb.o CC arch/x86/kernel/vm86_32.o CC arch/x86/kernel/early_printk.o CC arch/x86/kernel/ipipe.o... (2 Replies)
Discussion started by: mdop
2 Replies

10. Slackware

Error compile NFS

Tryng to compile nfs-utils to latest packages but.. make: Entering directory `/tmp/nfs-utils-1.2.8/utils/gssd' /bin/sh ../../libtool --tag=CC --mode=link gcc -Wall -Wextra -Wstrict-prototypes -pipe -O2 -fPIC -I/usr/kerberos/include -I/usr/kerberos/include -O2 -fPIC -ltirpc -o gssd... (4 Replies)
Discussion started by: Linusolaradm1
4 Replies
DLFCN(3)						   BSD Library Functions Manual 						  DLFCN(3)

NAME
dlopen, dlclose, dlsym, dlvsym, dladdr, dlctl, dlerror -- dynamic link interface LIBRARY
(These functions are not in a library. They are included in every dynamically linked program automatically.) SYNOPSIS
#include <dlfcn.h> void * dlopen(const char *path, int mode); int dlclose(void *handle); void * dlsym(void * restrict handle, const char * restrict symbol); void * dlvsym(void * restrict handle, const char * restrict symbol, const char *version); int dladdr(void * restrict addr, Dl_info * restrict dli); int dlctl(void *handle, int cmd, void *data); char * dlerror(void); DESCRIPTION
These functions provide an interface to the run-time linker ld.so(1). They allow new shared objects to be loaded into the process' address space under program control. The dlopen() function takes the name of a shared object as the first argument. The path argument can be specified as either an absolute pathname to a shared object or just the name of the shared object itself. When an absolute pathname is specified, only the path provided will be searched. When just a shared object name is specified, the same search rules apply that are used for ``intrinsic'' shared object searches. (see ld.elf_so(1)) Shared libraries take the following form: ``lib<name>.so[.xx[.yy]]''. The shared object is mapped into the address space, relocated, and its external references are resolved in the same way as is done with the implicitly loaded shared libraries at program startup. If the first argument is NULL, dlopen() returns a handle on the global symbol object. This object provides access to all symbols from an ordered set of objects consisting of the original program image and any dependencies loaded during startup. The mode parameter specifies symbol resolution time and symbol visibility. One of the following values may be used to specify symbol resolu- tion time: RTLD_NOW Symbols are resolved immediately. RTLD_LAZY Symbols are resolved when they are first referred to. This is the default value if resolution time is unspecified. One of the following values may be used to specify symbol visibility: RTLD_GLOBAL The object's symbols and the symbols of its dependencies will be visible to other objects. RTLD_LOCAL The object's symbols and the symbols of its dependencies will not be visible to other objects. This is the default value if visibility is unspecified. To specify both resolution time and visibility, bitwise inclusive OR one of each of the above values together. If an object was opened with RTLD_LOCAL and later opened with RTLD_GLOBAL, then it is promoted to RTLD_GLOBAL. Additionally, one of the following flags may be ORed into the mode argument: RTLD_NODELETE Prevents unload of the loaded object on dlclose(). The same behaviour may be requested by -z nodelete option of the static linker ld(1). RTLD_NOLOAD Only return valid handle for the object if it is already loaded in the process address space, otherwise do not load the object and return NULL. dlopen() returns a handle to be used in calls to dlclose(), dlsym(), dlvsym(), and dlctl(). If the named shared object has already been loaded by a previous call to dlopen() (and not yet unloaded by dlclose()), a handle referring to the resident copy is returned. dlclose() unlinks and removes the object referred to by handle from the process address space. If multiple calls to dlopen() have been done on this object, or the object was one loaded at startup time, or the object is a dependency of another object then the object is removed when its reference count drops to zero. dlclose() returns 0 on success and non-zero on failure. dlsym() looks for a definition of symbol in the shared object designated by handle, and all shared objects that are listed as dependencies. The symbol's address is returned. If the symbol cannot be resolved, NULL is returned. dlsym() may also be called with special handle values. dlsym() respects symbol visibility as specified by the dlopen() mode parameter. How- ever, the symbols of an object's dependencies are always visible to it. All shared objects loaded at program startup are globally visible. Only the symbols in the main executable that are referenced by a shared object at link time will be visible unless it has been linked with the --export-dynamic option where all of its symbols will be visible. The following special handle values may be used with dlsym(): NULL Interpreted as a reference to the executable or shared object from which the call is being made. Thus an object can reference its own symbols and the symbols of its dependencies without calling dlopen(). RTLD_DEFAULT All the visible shared objects and the executable will be searched in the order they were loaded. RTLD_NEXT The search for symbol is limited to the visible shared objects which were loaded after the one issuing the call to dlsym(). Thus, if dlsym() is called from the main program, all the visible shared libraries are searched. If it is called from a shared library, all subsequently visible shared libraries are searched. RTLD_SELF The search for symbol is limited to the shared object issuing the call to dlsym() and those shared objects which were loaded after it that are visible. dlvsym() does the same as dlsym() but takes a version string as an additional argument. Both the symbol and the version must match in order for the symbol to be resolved. dladdr() examines all currently mapped shared objects for a symbol whose address -- as mapped in the process address space -- is closest to but not exceeding the value passed in the first argument addr. The symbols of a shared object are only eligible if addr is between the base address of the shared object and the value of the symbol ``_end'' in the same shared object. If no object for which this condition holds true can be found, dladdr() will return 0. Otherwise, a non-zero value is returned and the dli argument will be used to provide information on the selected symbol and the shared object it is contained in. The dli argument points at a caller-provided Dl_info structure defined as follows: typedef struct { const char *dli_fname; /* File defining the symbol */ void *dli_fbase; /* Base address */ const char *dli_sname; /* Symbol name */ const void *dli_saddr; /* Symbol address */ } Dl_info; The structure members are further described as follows: dli_fname The pathname of the shared object containing the address addr. dli_fbase The base address at which this shared object is loaded in the process address space. This may be zero if the symbol was found in the internally generated ``copy'' section (see link(5)) which is not associated with a file. dli_sname points at the nul-terminated name of the selected symbol dli_saddr is the actual address (as it appears in the process address space) of the symbol. Note: both strings pointed at by dli_fname and dli_sname reside in memory private to the run-time linker module and should not be modified by the caller. In dynamically linked programs, the address of a global function will point to its program linkage table entry, rather than to the entry point of the function itself. This causes most global functions to appear to be defined within the main executable, rather than in the shared libraries where the actual code resides. dlctl() provides an interface similar to ioctl(2) to control several aspects of the run-time linker's operation. This interface is currently under development. dlerror() returns a character string representing the most recent error that has occurred while processing one of the other functions described here. If no dynamic linking errors have occurred since the last invocation of dlerror(), dlerror() returns NULL. Thus, invoking dlerror() a second time, immediately following a prior invocation, will result in NULL being returned. ERRORS
The error ``Cannot dlopen non-loadable /usr/lib/libpthread.so.1'' is generated when a program dlopen()s a module that needs libpthread but isn't linked against it itself. SEE ALSO
ld(1), rtld(1), link(5) HISTORY
Some of the dl* functions first appeared in SunOS 4. BSD
June 25, 2011 BSD
All times are GMT -4. The time now is 11:23 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy