LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Shared library creation ...... Problem... Plz Help.. (https://www.linuxquestions.org/questions/programming-9/shared-library-creation-problem-plz-help-308106/)

rajsun 03-31-2005 02:26 AM

Shared library creation ...... Problem... Plz Help..
 
Hi all,
I have written two small programs as I have mentioned below..

==================================
util1.c
---------------------------------------
int util1(char *str)
{
printf("1. %s\n");
return 0;
}
---------------------------------------
util2.c
---------------------------------------
int util2(char *str)
{
printf("2. %s\n");
return 0;
}
---------------------------------------
==================================

And I compiled above two file :

$ : gcc -fPIC -c util1.c
$ : gcc -fPIC -c util2.c

Now when i tryed to create shared library using following command :

$ : gcc -shared libmyutil.so util1.o util2.o

===================================
main problem.......... here
-----------------------------------------------
I got the following message :

libmyutil.so : no such file or directory
===================================

Plz tell me how to create the Shared library..............

With regard
Rajesh.

teval 03-31-2005 10:14 AM

-lmyutil should work.

Look below for a more comprehensive answer.

http://crasseux.com/books/ctutorial/...a-library.html

doctormetal 03-31-2005 11:09 AM

Re: Shared library creation ...... Problem... Plz Help..
 
Quote:

Originally posted by rajsun
==================================

$ : gcc -shared libmyutil.so util1.o util2.o

===================================
main problem.......... here
-----------------------------------------------
I got the following message :

libmyutil.so : no such file or directory
===================================

Plz tell me how to create the Shared library..............

With regard
Rajesh.

libmyutil.so is an output file, not an input file, so you must prepend -o to it.

So it must be:
Code:

gcc -shared -o libmyutil.so util1.o util2.o


All times are GMT -5. The time now is 02:38 AM.