LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 03-31-2005, 02:26 AM   #1
rajsun
Member
 
Registered: Mar 2005
Posts: 61

Rep: Reputation: 15
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.
 
Old 03-31-2005, 10:14 AM   #2
teval
Member
 
Registered: Jul 2003
Location: Toronto, Canada
Distribution: Gentoo
Posts: 720

Rep: Reputation: 30
-lmyutil should work.

Look below for a more comprehensive answer.

http://crasseux.com/books/ctutorial/...a-library.html
 
Old 03-31-2005, 11:09 AM   #3
doctormetal
LQ Newbie
 
Registered: Nov 2004
Posts: 9

Rep: Reputation: 0
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with opening shared library using dlopen() in Red Hat Linux phani@tcs Linux - General 1 01-10-2006 03:49 PM
MAndrake 10 library problem : error while loading shared libraries falojah Linux - Software 13 09-22-2005 06:18 AM
Commandline legth problem linking a shared library DavePrince Linux - Software 0 07-20-2005 08:19 AM
howto compile bin with my library using all-static and shared linked standart library stpg Programming 4 06-29-2004 04:20 AM
shared library problem with rpm nate1002 Linux - Software 0 02-13-2004 02:52 PM


All times are GMT -5. The time now is 06:59 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration