problem to compile with...

O

os2

hi

i tried to improve performance on for some trigonometry calcule

i read
http://www.javaworld.com/javatips/jw-javatip141.html?

i do

tmp@linux:~/bench> echo $CLASSPATH
/usr/lib/j2sdk1.4.2_03:/home/tmp/bench/java


tmp@linux:~/bench> javac MathLib.java

tmp@linux:~/bench> javah -jni -o MathLib.h -classpath . MathLib

i have some error with this command..

tmp@linux:~/bench> gcc -I/usr/lib/j2sdk1.4.2_03
-I/usr/lib/j2sdk1.4.2_03/include/linux Math.c -o MathLib.so
/usr/lib/gcc-lib/i586-suse-linux/3.3.3/../../../crt1.o(.text+0x18): in
function « _start »:
.../sysdeps/i386/elf/start.S:98: undefined reference to `main'
/tmp/cc8K7UyJ.o(.text+0x1c): in function « Java_MathLib_sin »:
: undefined reference to `sin' /tmp/cc8K7UyJ.o(.text+0x41): in
function « Java_MathLib_cos »:
: undefined reference to `cos' /tmp/cc8K7UyJ.o(.text+0x66): in
function « Java_MathLib_sqrt »:
: undefined reference to `sqrt'


how to resolve that?


MathLib.java file

public class MathLib
{
public static native double sin(double radians);
public static native double cos(double radians);
public static native double sqrt(double value);

static
{
System.loadLibrary("MathLib");
}
}


Math.c file


#include <jni.h>
#include <math.h>
#include "MathLib.h"
#include <stdio.h>

JNIEXPORT jdouble JNICALL Java_MathLib_sin(JNIEnv *env, jobject obj,
jdouble value)
{
return(sin(value));
}

JNIEXPORT jdouble JNICALL Java_MathLib_cos(JNIEnv *env, jobject obj,
jdouble value)
{
return(cos(value));
}

JNIEXPORT jdouble JNICALL Java_MathLib_sqrt(JNIEnv *env, jobject obj,
jdouble value)
{
return(sqrt(value));
}




MathLib.h is generate automatically by javah....

/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class MathLib */

#ifndef _Included_MathLib
#define _Included_MathLib
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: MathLib
* Method: sin
* Signature: (D)D
*/
JNIEXPORT jdouble JNICALL Java_MathLib_sin
(JNIEnv *, jclass, jdouble);

/*
* Class: MathLib
* Method: cos
* Signature: (D)D
*/
JNIEXPORT jdouble JNICALL Java_MathLib_cos
(JNIEnv *, jclass, jdouble);

/*
* Class: MathLib
* Method: sqrt
* Signature: (D)D
*/
JNIEXPORT jdouble JNICALL Java_MathLib_sqrt
(JNIEnv *, jclass, jdouble);

#ifdef __cplusplus
}
#endif
#endif



any idea?
 
M

Minti

os2 said:
hi

i tried to improve performance on for some trigonometry calcule

i read
http://www.javaworld.com/javatips/jw-javatip141.html?

i do

tmp@linux:~/bench> echo $CLASSPATH
/usr/lib/j2sdk1.4.2_03:/home/tmp/bench/java


tmp@linux:~/bench> javac MathLib.java

tmp@linux:~/bench> javah -jni -o MathLib.h -classpath . MathLib

i have some error with this command..

tmp@linux:~/bench> gcc -I/usr/lib/j2sdk1.4.2_03
-I/usr/lib/j2sdk1.4.2_03/include/linux Math.c -o MathLib.so
/usr/lib/gcc-lib/i586-suse-linux/3.3.3/../../../crt1.o(.text+0x18): in
function « _start »:
../sysdeps/i386/elf/start.S:98: undefined reference to `main'
/tmp/cc8K7UyJ.o(.text+0x1c): in function « Java_MathLib_sin »:
: undefined reference to `sin' /tmp/cc8K7UyJ.o(.text+0x41): in
function « Java_MathLib_cos »:
: undefined reference to `cos' /tmp/cc8K7UyJ.o(.text+0x66): in
function « Java_MathLib_sqrt »:
: undefined reference to `sqrt'


how to resolve that?

Pass -lm option to your gcc. BTW 2 things

a) Your issue is covered in FAQ.
c) It's OT in comp.lang.c a better place would have been
comp.programming.

<snip code>
--
Imanpreet Singh Arora
Zmoc.Zliamg@Zteerpnami
Remove Z to mail
"Things may come to those who wait, but only the things left by those who
hustle."
Abraham Lincoln
 
J

Jack Klein

hi

i tried to improve performance on for some trigonometry calcule

i read
http://www.javaworld.com/javatips/jw-javatip141.html?

i do

tmp@linux:~/bench> echo $CLASSPATH
/usr/lib/j2sdk1.4.2_03:/home/tmp/bench/java


tmp@linux:~/bench> javac MathLib.java

tmp@linux:~/bench> javah -jni -o MathLib.h -classpath . MathLib

i have some error with this command..

Absolutely everything about Java is off-topic here. I suggest that
you ask this in a Java group.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top