* linking to jni code
@ 2009-05-04 6:45 abhishek desai
2009-05-04 6:47 ` abhishek desai
2009-05-05 9:54 ` Andrew Haley
0 siblings, 2 replies; 3+ messages in thread
From: abhishek desai @ 2009-05-04 6:45 UTC (permalink / raw)
To: java
Hi,
I am using the below command to compile a java program making calls to
native functions implemented using JNI.
gcj --main=MyApp -fjni MyApp.class MyApp.o -o MyApp
Here MyApp.class is the class file generated from MyApp.java
MyApp.o is the object file generated from MyApp.c implementing the JNI
calls InitBase and PrintString.
The command generated the executable but when executing it gives the
following error.
Exception in thread "main" java.lang.UnsatisfiedLinkError: InitBase
at EpgApp.InitBase(MyApp)
at EpgApp.main(MyApp)
Looks like the MyApp.o file does not get linked into the application.
Is there a way to get it linked into the Application statically?
^ permalink raw reply [flat|nested] 3+ messages in thread
* linking to jni code
2009-05-04 6:45 linking to jni code abhishek desai
@ 2009-05-04 6:47 ` abhishek desai
2009-05-05 9:54 ` Andrew Haley
1 sibling, 0 replies; 3+ messages in thread
From: abhishek desai @ 2009-05-04 6:47 UTC (permalink / raw)
To: java
Hi,
I am using the below command to compile a java program making calls to
native functions implemented using JNI.
gcj --main=MyApp -fjni MyApp.class MyApp.o -o MyApp
Here MyApp.class is the class file generated from MyApp.java
MyApp.o is the object file generated from MyApp.c implementing the JNI
calls InitBase and PrintString.
The command generated the executable but when executing it gives the
following error.
Exception in thread "main" java.lang.UnsatisfiedLinkError: InitBase
at MyApp.InitBase(MyApp)
at MyApp.main(MyApp)
Looks like the MyApp.o file does not get linked into the application.
Is there a way to get it linked into the Application statically?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: linking to jni code
2009-05-04 6:45 linking to jni code abhishek desai
2009-05-04 6:47 ` abhishek desai
@ 2009-05-05 9:54 ` Andrew Haley
1 sibling, 0 replies; 3+ messages in thread
From: Andrew Haley @ 2009-05-05 9:54 UTC (permalink / raw)
To: abhishek desai; +Cc: java
abhishek desai wrote:
> I am using the below command to compile a java program making calls to
> native functions implemented using JNI.
>
> gcj --main=MyApp -fjni MyApp.class MyApp.o -o MyApp
>
> Here MyApp.class is the class file generated from MyApp.java
> MyApp.o is the object file generated from MyApp.c implementing the JNI
> calls InitBase and PrintString.
>
> The command generated the executable but when executing it gives the
> following error.
>
> Exception in thread "main" java.lang.UnsatisfiedLinkError: InitBase
> at EpgApp.InitBase(MyApp)
> at EpgApp.main(MyApp)
>
> Looks like the MyApp.o file does not get linked into the application.
> Is there a way to get it linked into the Application statically?
You'll have to make sure there is a reference to it from somewhere in the
app. The easiest way is to define a symbol in the C code:
int FooBarBaz;
and then refer to it when building the app:
gcj -Wl,--undefined=FooBarBaz -c -fjni MyApp.class -o MyApp.o
Andrew.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-05-05 9:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-04 6:45 linking to jni code abhishek desai
2009-05-04 6:47 ` abhishek desai
2009-05-05 9:54 ` Andrew Haley
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).