sudhakar_koundinya
asked on
Exact option for compiling C Files for JNI
Hello all,
What exact option i need to give to create a shared library in Linux.
I am able to compile to get shared libray in windows. But failing in linux.
And Don't propose me the links. I have tried almost all . My Problem is I am not a programmer for linux environment. So please help me with the step by step procedure
Thanks
Sudhakar
What exact option i need to give to create a shared library in Linux.
I am able to compile to get shared libray in windows. But failing in linux.
And Don't propose me the links. I have tried almost all . My Problem is I am not a programmer for linux environment. So please help me with the step by step procedure
Thanks
Sudhakar
This depends on what compiler(s) is/are installed on your system
ASKER
I am compiling on Redhat 7.0 linux using gcc compiler
ASKER
BTW
library path and executable paths are set correctly.
I thing i am missing some thing at compiling options only
Thanks
Sudhakar
library path and executable paths are set correctly.
I thing i am missing some thing at compiling options only
Thanks
Sudhakar
Different versions of gcc have different options. Try
man gcc
at the command line for yours
man gcc
at the command line for yours
ASKER
i have already done that
gcc -shared -W1 -o xyz.so xyz.o
to compile use something like:
gcc -c -fPIC xyz.c
you may need to add -I options for any includes that are required
eg. -I/usr/includes
gcc -c -fPIC xyz.c
you may need to add -I options for any includes that are required
eg. -I/usr/includes
> java.lang.UnsatisfiedLinkE rror: no FileValidator in shared library path
Once you have made your lib make sure it is in a directory in LD_LIBRARY_PATH
Once you have made your lib make sure it is in a directory in LD_LIBRARY_PATH
Despite the fact that you ask for no links, imho you'd be better off looking at the link from where those extracts just posted have been taken as there's further useful info there:
http://quong.best.vwh.net/java/native102.html
http://quong.best.vwh.net/java/native102.html
what are u talking about???
that link probaly uses the same option cause that's what you use.
I'm sure you can find a miriad of links that use the same options.
that link probaly uses the same option cause that's what you use.
I'm sure you can find a miriad of links that use the same options.
ASKER
CEHJ
I have alread saw that link
Objects
I have alread saw that link
Objects
ASKER
CEHJ
I have alread saw that link
Objects
gcc -I/home/jdk1.4/include -I/home/jdk1.4/include/lin ux FileValidator.c
That is the compiler options I have used. Is that my mistake?
I have alread saw that link
Objects
gcc -I/home/jdk1.4/include -I/home/jdk1.4/include/lin
That is the compiler options I have used. Is that my mistake?
ASKER
BTW
library path and executable paths are set correctly.
I think i am missing some thing at compiling options only
Thanks
Sudhakar
library path and executable paths are set correctly.
I think i am missing some thing at compiling options only
Thanks
Sudhakar
yes try including -fPIC
ASKER
please let me try.
Thanks
Sudhakar
Thanks
Sudhakar
Hi sudhakar_koundinya,
Try to specify the extension when you load the library:
static { System.loadLibrary("FileVa lidator.so "); }
Otherwise, check the library name, because with linux filenames, uppercase characters are not equals to lowercase characters.
Try to specify the extension when you load the library:
static { System.loadLibrary("FileVa
Otherwise, check the library name, because with linux filenames, uppercase characters are not equals to lowercase characters.
ASKER
I have failed with System.loadLibrary but worked with System.load
ASKER
And Compiler options I have used as suggested by objects
>> I have failed with System.loadLibrary but worked with System.load
maybe the LD_LIBRARY_PATH variable is not set correctly. If you have many library paths, the separator is ':', and must not include library filenames.
http://www.public.asu.edu/~wjanjua/java/jni/
http://www.netspade.com/articles/java/native.xml
maybe the LD_LIBRARY_PATH variable is not set correctly. If you have many library paths, the separator is ':', and must not include library filenames.
http://www.public.asu.edu/~wjanjua/java/jni/
http://www.netspade.com/articles/java/native.xml
ASKER
WebStorm,
I did that already. The Library paths are setted correctly but still giving problem :-(
I did that already. The Library paths are setted correctly but still giving problem :-(
> I have failed with System.loadLibrary
> but worked with System.load
That suggests the shared lib is ok, but it is not finding it
what are you passing as lib name?
What is your libs filename?
where is your lib located?
What is the value of LD_LIBRARY_PATH?
> but worked with System.load
That suggests the shared lib is ok, but it is not finding it
what are you passing as lib name?
What is your libs filename?
where is your lib located?
What is the value of LD_LIBRARY_PATH?
ASKER
Hi all again
I understand that library path setting should be correct. And I did the same. But Still it is not working
:-((
I understand that library path setting should be correct. And I did the same. But Still it is not working
:-((
ASKER
what are you passing as lib name?
ReadPST
What is your libs filename?
ReadPST
where is your lib located?
/home/sudhakar/sudha/Outlo ok/ReadPST Project
What is the value of LD_LIBRARY_PATH?
???
ReadPST
What is your libs filename?
ReadPST
where is your lib located?
/home/sudhakar/sudha/Outlo
What is the value of LD_LIBRARY_PATH?
???
ASKER
BTW
Sorry for My late response on this thread. Because I was busy with some other works during these days and neglet this application
Thanks
Sudhakar
Sorry for My late response on this thread. Because I was busy with some other works during these days and neglet this application
Thanks
Sudhakar
>What is your libs filename?
>ReadPST
try renaming it to ReadPST.so
>ReadPST
try renaming it to ReadPST.so
ASKER
Errrrr............
>>try renaming it to ReadPST.so
I was in hurry to post the message it is ReadPST.so only
>>try renaming it to ReadPST.so
I was in hurry to post the message it is ReadPST.so only
> What is the value of LD_LIBRARY_PATH?
> ???
and what is that value exactly?
> ???
and what is that value exactly?
ASKER
LD_LIBRARY_PATH=`pwd`
export LD_LIBRARY_PATH
export LD_LIBRARY_PATH
and what directory do you run that from, ie. what is pwd?
ASKER
According to example given at java.sun.com
I give that. pwd is current directory
I give that. pwd is current directory
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
java.lang.UnsatisfiedLinkE
at java.lang.Runtime.loadLibr
at java.lang.System.loadLibra
at FileValidator .<clinit>(FileValidator .java:41)
at FileValidator .main(FileValidator .java:26)