Linking errors with GCJ and SWT

James Lee jlee23@umbc.edu
Wed Feb 16 21:36:00 GMT 2005


I tried making a library out of my swt.jar, then linking against but
just got more errors.  Here is how I did it:

        jlee@thinkpad ~ $ gcj -fPIC -shared -o libswt.so /usr/share/swt-3/lib/swt.jar
        jlee@thinkpad ~ $ gcj -L. -lswt --main=Test Test.java
        ./libswt.so: undefined reference to `org::eclipse::swt::internal::gtk::OS::memmove(org::eclipse::swt::internal::gtk::GtkWidgetClass*, int)'
        ./libswt.so: undefined reference to `org::eclipse::swt::internal::mozilla::XPCOM::VtblCall(int, int, int, JArray<char>*, bool)'
        ./libswt.so: undefined reference to `org::eclipse::swt::internal::mozilla::XPCOM::VtblCall(int, int, JArray<char>*, org::eclipse::swt::internal::mozilla::nsID*, JArray<bool>*)'
        ./libswt.so: undefined reference to `org::eclipse::swt::internal::gtk::OS::gdk_pixbuf_get_rowstride(int)'
        ./libswt.so: undefined reference to `org::eclipse::swt::internal::gtk::OS::gtk_widget_create_pango_layout(int, int)'
        ./libswt.so: undefined reference to `org::eclipse::swt::internal::gtk::OS::g_list_free_1(int)'
        ./libswt.so: undefined reference to `org::eclipse::swt::internal::gtk::OS::gtk_tree_model_iter_nth_child(int, int, int, int)'
        ./libswt.so: undefined reference to `org::eclipse::swt::internal::gtk::OS::memmove(org::eclipse::swt::internal::gtk::PangoLayoutRun*, int, int)'
        ./libswt.so: undefined reference to `org::eclipse::swt::internal::gtk::OS::gtk_entry_set_visibility(int, bool)'
        ./libswt.so: undefined reference to `org::eclipse::swt::internal::gtk::OS::gtk_tree_selection_select_iter(int, int)'
        ./libswt.so: undefined reference to `org::eclipse::swt::internal::gtk::OS::gtk_accel_label_set_accel_widget(int, int)'
        ./libswt.so: undefined reference to `org::eclipse::swt::internal::gtk::OS::gtk_hbox_new(bool, int)'
        ./libswt.so: undefined reference to `org::eclipse::swt::internal::gtk::OS::gtk_file_filter_set_name(int, JArray<char>*)'
        ---AND IT GOES ON---

I have found a way that it works after a lot of searching on Google
which pointed me to
http://forum.java.sun.com/thread.jspa?threadID=560271&messageID=2752866 .  The command in the second reply worked for me but left me with a HUGE binary (5.5M).  Leaving the -fjni out causes it to fail with more undefined references.  Using the shared library that I generated from the same jar along with -fjni caused undefined references.  What is going on here?

Thanks for the help!

On Tue, 2005-02-15 at 22:42 -0500, Bryce McKinlay wrote:
> Those look like the JNI libraries for SWT, ie they contain the C code 
> part of SWT? You'll need to compile the SWT Java code (jar file) into 
> its own .so, and link against that.
> 
> You don't need to link the JNI library as those will be loaded dynamically.
> 
> Bryce



More information about the Java mailing list