LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   dynamically (https://www.linuxquestions.org/questions/programming-9/dynamically-277184/)

phoenix_fei 01-13-2005 12:32 AM

dynamically
 
hello:
I create a libmydll.so file,and now I want to invoke it.But I do not use
"dlopen()" to invoke it. How to invoke ?
thanks

Hko 01-13-2005 04:52 AM

Make sure the directory your .so file is stored is listed in /etc/ld.so.conf. Then (as root) run "ldconfig" and try again.

phoenix_fei 01-14-2005 12:51 AM

hello
I try it ,but not success ???

Inunu 01-14-2005 05:37 AM

Try following all steps:

1. Compile/link source/object files of your shared library with -fpic, -shared, -Wl,-soname

age.c
Code:

/* one simple function */
int age(){ return 25; }

gcc -fpic -shared -Wl,-soname=libage.so
This gives libage.so, a shared lib.

2. Compile/link your application source with -L and -l

myage.c
Code:

#include <stdio.h>

extern int age(); /* this line is normally in lib's header file */

int main(int argc, char *argv[]){
  printf("My age is %d.\n", age());
  return 0;
}

gcc -L. -lage -o myage myage.c
This gives myage exe file, dynamically linked to libage.so in *current directory*.

3. Run it with LD_LIBRARY_PATH (if libage.so is not going to be in one of listed folders in your /etc/ld.so.conf)

linux/tmp$ LD_LIBRARY_PATH=. ./myage
My age is 25.

phoenix_fei 01-16-2005 08:01 PM

hello,
I try ,but not success .why???

phoenix_fei 01-17-2005 07:51 PM

why

everyone
why not success in my comuter>>>>>


All times are GMT -5. The time now is 03:26 AM.