LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-26-2010, 09:25 AM   #1
shrivaths
LQ Newbie
 
Registered: Feb 2010
Posts: 2

Rep: Reputation: 0
Unhappy How to create .so file on fedora 7?


Hello friends,

I am working on JNI(Java Native Interface) on fedora 7 where i need to create a .so file of .c.(For example Hello.c to Hello.so).
But i am not getting options to be used with the "cc" command.
So please tell me the option or the command.
 
Old 03-26-2010, 09:49 AM   #2
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
this probably should go in the programming forum.
i know with c you can use gcc -c to create a shared object. keep in mind that object code simply doesnt have an enfty point.
 
Old 03-26-2010, 02:00 PM   #3
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,624

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
First fedora 7 is OLD and unsupported . Please install the current fedora 12
"example Hello.c to Hello.so)."
read the gcc docs
so you want to make an executable lib ( .o) and not a normal executable file
 
Old 03-26-2010, 02:12 PM   #4
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by shrivaths View Post
I am working on JNI(Java Native Interface) on fedora 7 where i need to create a .so file of .c
The main thing you need is -shared on the gcc command line.
I'm not sure what else you might need: Switches specific to JNI? Specific the version of gcc you're using (what version is that?) Specific to your architecture (I expect X86, but if it is X86_64, that requires some extra switches).

Quote:
Originally Posted by schneidz View Post
you can use gcc -c to create a shared object.
No. that is to create a .o file (an object file) not a .so file (shared object file).

Quote:
Originally Posted by John VV View Post
First fedora 7 is OLD and unsupported . Please install the current fedora 12
Interesting point. But I don't know how important that is. The version of GCC may be a more relevent question.

Quote:
read the gcc docs
That is harder than you might expect. The man page for gcc is so disorganised, incomplete and misleading to be basically worthless. The info documentation for GCC is terribly hard to navigate.

If you must read GCC documentation, I find the online HTML version to be at least practical to navigate, which compensates some for the poor organization. I don't know if that is even available for whatever old version of GCC the OP is using. I'm using 4.3.2, documented at:
http://gcc.gnu.org/onlinedocs/gcc-4.3.2/gcc/index.html

If you knew a moderate amount about GCC, but not much about how it is documented, you would click from there into GCC Command Options and from there into Options Controlling the Kind of Output and try to find where it tells you how to chose .so as the kind of output. No such luck.

The -shared switch is documented (sort of) in the section on Options for Linking

Last edited by johnsfine; 03-26-2010 at 03:10 PM.
 
Old 03-27-2010, 01:57 AM   #5
shrivaths
LQ Newbie
 
Registered: Feb 2010
Posts: 2

Original Poster
Rep: Reputation: 0
Thank you guys for your support

I got the so file using cc with -c option, and now i want to set the "library path".
But with some reference i got the information about the "ld.so.conf" where i need to edit the new path and have to update the ld.so.cache file.
I did the same thing but i am not able to execute that "ld.so.cache".
 
Old 03-27-2010, 06:49 AM   #6
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
I think you are way off track at the moment:

Quote:
Originally Posted by shrivaths View Post
I am working on JNI
It has been a while since I did JNI programming, so I forget some details. But I do recall some basic info.

A .so for JNI is not loaded when the executable (java) is loaded. It is loaded later by that executable. So the search rules that apply to .so files loaded with an executable don't apply. Java has its own, different, search rules for the .so files it loads later for JNI.

Quote:
Originally Posted by shrivaths View Post
with some reference i got the information about the "ld.so.conf" where i need to edit the new path and have to update the ld.so.cache file.
I'm pretty sure you don't want to edit ld.so.conf
First, because the .so for JNI is found by different rules.
Second, because you usually don't want to edit ld.so.conf even for .so files found the common way: You either want to put the .so where it would be found normally or change the LD_LIBRARY_PATH environment variable.

Quote:
I did the same thing but i am not able to execute that "ld.so.cache".
That's so far off track I can't even guess what you're trying to do.

Quote:
Originally Posted by shrivaths View Post
I got the so file using cc with -c option
As I explained earlier, that is also wrong.
 
Old 03-27-2010, 08:58 AM   #7
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
Quote:
Originally Posted by johnsfine View Post
...
No. that is to create a .o file (an object file) not a .so file (shared object file)...
hi i never knew the difference between a *.o and a *.so -- i thought they were the same. thanks for the correction.
 
  


Reply



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
Create a script that asks the user for a file and then appends the date to the file larry5757 Linux - Newbie 2 12-04-2009 06:33 AM
unable to create file & folder on fat32 file system while similiar other drives work sumeet inani Linux - Newbie 1 06-27-2009 11:46 AM
Create File Shell Syntax and pass data to the file FirstBorn Linux - General 22 07-31-2008 09:48 PM
Fedora 8 and NoMachine "Could not create lock file in /tmp/.tX1002-lock" ln3wb13 Linux - Software 3 05-17-2008 01:31 PM
CentOS 4 (Fedora Core) init script - create PID file cejennings_cr Linux - Newbie 1 07-10-2006 08:22 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:22 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration