I get the following error message, yet don't seem able to get past it. I am probably missing something in the link line of the makefile but can't see what library I am missing. I've written a simple JNI Hello World and simple OpenGL program using a very similar makefile (modified to produce an executable rather than a shared lib for the OpenGL program), which both run without a problem.
Exception in thread "main" java.lang.UnsatisfiedLinkError: /uufs/chpc.utah.edu/common/home/u0544384/Desktop/OpengL_Test/libMyWindow.so: /uufs/chpc.utah.edu/common/home/u0544384/Desktop/OpengL_Test/libMyWindow.so: undefined symbol: JAWT_GetAWT
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1803)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1728)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1028)
at MyWindow.<clinit>(MyWindow.java:14)
Could not find the main class: MyWindow. Program will exit.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
| import java.awt.Frame; import java.awt.BorderLayout; import java.awt.Canvas; import java.awt.Label; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import java.awt.Graphics; import javax.swing.Timer; public class MyWindow extends Canvas implements ActionListener { static { System.out.println( "java.library.path := " + System.getProperty("java.library.path") ); System.loadLibrary("MyWindow"); } public final static int TIMER_SECONDS = 100; public static void main( String[] argv ) { Frame f = new Frame(); f.setSize(300,400); f.setLayout(new BorderLayout()); f.setTitle("OpenGL from Java"); MyWindow w = new MyWindow(); f.add(w,BorderLayout.CENTER); f.add(new Label("test"),BorderLayout.SOUTH); f.setBounds(300,300,300,300); f.setVisible(true); } private boolean bInitOpenGL = false; public void actionPerformed(ActionEvent evt) { if(bInitOpenGL == false) { bInitOpenGL = true; initializeOpenGL(); } paintOpenGL(); } public void addNotify() { super.addNotify(); javax.swing.Timer timer = new Timer(TIMER_SECONDS,this); timer.start(); } public void removeNotify() { super.removeNotify(); cleanupOpenGL(); } public native void paintOpenGL(); public native void initializeOpenGL(); public native void cleanupOpenGL(); } |
1 2 3 4 5 6 7 8 9 10 11 12
| CC = gcc -pedantic -ansi -shared SRC = MyWindow.cpp all: $(CC) $(SRC) -o libMyWindow.so -L/usr/X11R6/lib -lGL -lGLU -lXxf86vm -lstdc++ clean: @echo Cleaning up... @rm -f *.so *.o @echo Done. |