- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- error: java.lang.UnsatisfiedLinkError: Can't load ...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2009 02:23 AM
01-07-2009 02:23 AM
error: java.lang.UnsatisfiedLinkError: Can't load library: /home/nalgo01/cImpl
In the below u can find a sample Java™ program that calls a native method, which has a C implementation:
OS : HP-UX IA64
java : 1.6
Here is the sample program.
####################################
//
// File TestJava2CallingNative.java
//
class TestJava2CallingNative {
native static void sayHelloWorld();
public static void main(String args[])
{
String libname = args[0];
try {
System.loadLibrary(libname);
System.out.println("Library " +
libname + " successfully loaded");
}
catch (UnsatisfiedLinkError Err) {
System.out.println("error: " + Err);
return;
}
System.out.println("Calling sayHelloWorld");
sayHelloWorld();
System.out.println("All done");
}
}
Compile this class:
$
Output:
TestJava2CallingNative.class
Generate the JNI header file for this class. You must have the current directory in your CLASSPATH for the javah command to find your newly compiled class file.
$
Output:
TestJava2CallingNative.h
#########################################
Here is the sample c code
Here is the sample C native method implementation for sayHelloWorld:
/*
* File cImpl.c
*/
#include "TestJava2CallingNative.h"
#include
JNIEXPORT void JNICALL
Java_TestJava2CallingNative_sayHelloWorld(JNIEnv *env, jclass class)
{
printf("C says HelloWorld via stdio\n");
}
To compile this C source file:
$ cc -Ae +u4 +z -c -mt -I
-I
Output:
cImpl.o
Create the shared library containing the native method implementation:
ld -b -o libcImpl.so cImpl.o ( Is this creation correct for HP-UX IA64 )
Output:
libcImpl.so
Have set the path as :
To execute the Java™ program, you must set the SHLIB_PATH environment variable to contain the location of the directory that contains libcImpl.so
Once i set the PATH i did the following steps
$ export SHLIB_PATH=.:$SHLIB_PATH
$
This is what i have done...
While extecuting the
$
above line i got the error message as
# java TestJava2CallingNative cImpl
error: java.lang.UnsatisfiedLinkError: Can't load library: /home/nalgo01/cImpl
what is the solution for this. Does i need to set any other options while compiling or linking.
Make sure i am using HP-UX IA64.
Any help is apreceated
Thanks in advance
Gopi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2009 05:27 AM
01-07-2009 05:27 AM
Re: error: java.lang.UnsatisfiedLinkError: Can't load library: /home/nalgo01/cImpl
Should'nt /home/nalgo01 (absolute path) be in your SHLIB_PATH when thats where clmpl is located?
export SHLIB_PATH=$SHLIB_PATH:/home/nalgo01
Yours
Danny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2009 06:28 AM
01-07-2009 06:28 AM
Re: error: java.lang.UnsatisfiedLinkError: Can't load library: /home/nalgo01/cImpl
Have tried setting the SHLIB_PATH to /home/nalgo01 (absolute path)
But no result. Same error is being produced
Any help is appreceated
Thanks in advance
Gopi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2009 08:22 PM
01-08-2009 08:22 PM
Re: error: java.lang.UnsatisfiedLinkError: Can't load library: /home/nalgo01/cImpl
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1300275
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1299685
>what is the solution for this? Do I need to set any other options while compiling or linking?
I have no problems compiling, linking and running this test case using cc(1) and java 1.5. Both in 32 and 64 bit.
And no problems with gcc 4.2.1.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2009 10:23 PM
01-11-2009 10:23 PM
Re: error: java.lang.UnsatisfiedLinkError: Can't load library: /home/nalgo01/cImpl
I Compiled the above test case using
# cc +z -c -dynamic +DD64 -Ae +u4 -mt \
-I
-I
It compiled properly, and linked using ld
# ld -b +k +s +std -o libcImpl.so cImpl.o \
-lstd_v2 -lCsup -lunwind -lm
The test application ran successfully
> I have no problems compiling, linking and running this test case using cc(1) and java 1.5. Both in 32 and 64 bit.
Can u post what are the options u have used for compileing and linking using cc.
> And no problems with gcc 4.2.1.
Can u post the options for compiling and linking using gcc.
Dennis one more info needed.
1.) My c application retreives the system related info such as
- pid, No of CPU's, Process CPU
utilization, Aggregate CPU utilization
I retreive these info using getrusage system call.
Q : i have compiled this appication using
the the above cc options. it compiled sucessfully. I linked this appication using the same linking options as above.
When i tried to use the executable it is giving the error as
error: java.lang.UnsatisfiedLinkError: Can't load library: /home/nalgo01/libIA64.so
My question is does these system calls have any other dependencies other than what i used while linking ie ( -lstd_v2 -lCsup -lunwind -lm )
What are the libraries which depend on native system calls such as getrusage.
Any help is apreceated
Thanx in advance
Gopi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2009 02:24 AM
01-12-2009 02:24 AM
Re: error: java.lang.UnsatisfiedLinkError: Can't load library: /home/nalgo01/cImpl
Can u look into this once.
Regards,
Gopi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2009 02:29 AM
01-12-2009 02:29 AM
Re: error: java.lang.UnsatisfiedLinkError: Can't load library: /home/nalgo01/cImpl
> cc +z -c -dynamic +DD64 -Ae +u4 -mt \
-I
-I
I left out -dynamic since it is the default.
>linked using ld
>ld -b +k +s +std -o libcImpl.so cImpl.o \
-lstd_v2 -lCsup -lunwind -lm
You must NOT use ld to link aC++ shlibs. You must use aCC -b.
I just used what was documented: ld -b -o libcImpl.so cImpl.o
>Can you post what are the options you have used for compiling and linking using cc.
What you had before.
>Can you post the options for compiling and linking using gcc.
What you had previously.
>Q: I linked this application using the same linking options as above.
Use the cut down ld command.
>When i tried to use the executable it is giving the error as
>error: java.lang.UnsatisfiedLinkError: Can't load library: /home/nalgo01/libIA64.so
This java error is garbage, it doesn't tell you anything.
>does these system calls have any other dependencies other than what i used while linking ie (-lstd_v2 -lCsup -lunwind -lm)
Do not use these aC++ shlibs.
>What are the libraries which depend on native system calls such as getrusage.
They are all in libc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2009 02:31 AM
01-12-2009 02:31 AM
Re: error: java.lang.UnsatisfiedLinkError: Can't load library: /home/nalgo01/cImpl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2009 04:53 AM
01-12-2009 04:53 AM
Re: error: java.lang.UnsatisfiedLinkError: Can't load library: /home/nalgo01/cImpl
thanx a lot for u reply :-)
>> >What are the libraries which depend on native system calls such as getrusage.
>They are all in libc.
i have tried that native appication ie which retrives pid, No of CPU's, so on...
I compiled & linked as u have have mentioned.
Linking options :
ld -b -o libIntroscopeHpuxItanium64Stats.so java_interface.o -lc (as u have mentioned all system call libraries are stored in libc )
It got linked properly.
I used this executable in my appication but got an error :
#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
# SIGSEGV (11) at pc=c00000000774e1c1, pid=20716, tid=19
#
# Java VM: Java HotSpot(TM) 64-Bit Server VM (1.5.0.11 jinteg:11.07.07-18:21 IA64W mixed mode)
# Problematic frame:
# C [libIntroscopeHpuxItanium64Stats.so+0x21c1] Java_com_wily_introscope_agent_platform_hpux_HPUXPlatformStatisticsBackEnd_getCPUIndexMap+0x191
#
detailed log is atached for clear understanding.
Thanks in Advance Dennis,
Gopi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2009 03:47 PM
01-12-2009 03:47 PM
Re: error: java.lang.UnsatisfiedLinkError: Can't load library: /home/nalgo01/cImpl
You shouldn't need to add -lc here.
>I used this executable in my application but got an error:
# Problematic frame: C
[libIntroscopeHpuxItanium64Stats.so+0x21c1] Java_com_wily_introscope_agent_platform_hpux_HPUXPlatformStatisticsBackEnd_g
etCPUIndexMap+0x191
Notice how java cleverly blames your JNI function. :-)
You need to debug your code. Compile with -g and you can use gdb to print out variables.