ld: Undefined symbols: _GetStringUTFChars _NewStringUTF /usr/bin/libtool: internal link edit command failed
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anbu_D
Posted On:   Wednesday, March 21, 2007 04:45 AM

hi All i am trying to make a dynamic jnilib file in intel based mac Shell> javac GetFileContents.java Shell> javah GeTfilecontents Shell> cc -c -I/System/Library/Frameworks/JavaVM.framework/Headers main.c Shell>cc -dynamiclib -o libGetFileContents.jnilib main.o -framework JavaVM ld: Undefined symbols: _GetStringUTFChars _NewStringUTF /usr/bin/libtool: internal link edit command failed i do not know why this error is thrown, dose any one help me to over come this, i am a new user of mac and jni Thankyou in advance Anbu The code is given bellow    More>>

hi All

i am trying to make a dynamic jnilib file in intel based mac


Shell> javac GetFileContents.java
Shell> javah GeTfilecontents
Shell> cc -c -I/System/Library/Frameworks/JavaVM.framework/Headers main.c



Shell>cc -dynamiclib -o libGetFileContents.jnilib main.o -framework JavaVM



ld: Undefined symbols:
_GetStringUTFChars
_NewStringUTF
/usr/bin/libtool: internal link edit command failed




i do not know why this error is thrown, dose any one help me to over come this, i am a new user of mac and jni


Thankyou in advance

Anbu



The code is given bellow



//GetFileContents.java

import java.io.*;
import java.lang.*;
public class GetFileContents
{
public static native String getContents(int start,int end,String Filename);
static
{
try{
System.loadLibrary("GetFileContents");
}catch(Exception e){}
}
public GetFileContents()
{

}
public String getWord(int start,int end ,String filepath)
{
File stream = new File(filepath.trim());
System.out.println("The File path is "+ filepath);
System.out.println(" The start position is "+ start);
System.out.println(" The End position is "+ end);
String s=getContents(start,end, stream.getAbsolutePath());
//System.out.println(s);
return s;
}
public static void main(String arg[])
{
GetFileContents gFile=new GetFileContents();
File stream = new File("doc/text.txt");
String s=gFile.getWord(100,200, stream.getAbsolutePath());
System.out.println(s);
}
}



and the code for .c file is

/* main.c */

#include
#include
#include "GetFileContents.h"
#include "jni.h"


JNIEXPORT jstring JNICALL Java_GetFileContents_getContents
(JNIEnv *env, jclass cls, jint stPos, jint enPos, jstring FilePath )
{
FILE *stream1;
jboolean *iscopy=false;
jstring meaning;
fpos_t startpos,endpos,diffpos;
// jlong startpos,endpos,diffpos;

int i,length;
int startposition,endposition;
const char *filepath=GetStringUTFChars(env,FilePath,iscopy);


startposition=(int)stPos;
endposition=(int)enPos;
char *buffer=(char*)malloc(endposition-startposition);
startpos=(fpos_t)startposition;
endpos=(fpos_t)endposition;

diffpos=(endpos-startpos) + 1;
if((stream1=fopen(filepath, "r"))!=NULL)
{
i=0;
fsetpos(stream1,&startpos);
fread(buffer,sizeof(char),diffpos,stream1);


length=strlen(buffer);
printf("The meanings from the postion are:
");
printf("%s",buffer);
fclose(stream1);
meaning= NewStringUTF(env,buffer);
free(buffer);
buffer=NULL;
}
return meaning;

}

   <<Less
About | Sitemap | Contact