Mohan Raja Gadikota
Mohan Raja Gadikota

Reputation: 21

Which Qt library contains QApplication

I'm using swig to wrap an QT appliction with java (using JNI) , all of procedures gone smooth until , It raised an exception undefined QApplication Exception.
I thing the problem is that JVM was unable to find the library of QApplication if I load the *.so(Shared Object) of QApplication I somehow manage to eliminate this error.
Please tell me where can I find the *.so (shared Object) of QApplication
Thank you in advance.

    //mohan.cpp
 #include <QApplication>
 #include <QPushButton>
 int initQ()
 {
     char *argv[2];
     argv[0]="name";
     argv[1]="texteditapplication";
     int argc=2;
     QApplication app(argc, argv);

     QPushButton hello("Hello world!");
     hello.resize(100, 30);

     hello.show();
     return app.exec();
 }

//mohan.i
%module mohan

%{
/* Put headers and other declarations here */
 #include <QApplication>
 #include <QPushButton>
int initQ();
%}
extern int initQ();

//runme.java
public class runme {
  static {
System.out.println(System.getProperty("java.library.path"));
 System.loadLibrary("mohan");
  }

  public static void main(String argv[]) {
    System.out.println(mohan.initQ());  
    System.out.println();
  }
}

//execution

[mohan@mohan mohan]$ g++ -fpic -c mohan.cpp mohan_wrap.cxx -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/media/mohan/QtSDK/Desktop/Qt/474/gcc/mkspecs/default -I. -I/media/mohan/QtSDK/Desktop/Qt/474/gcc/include/QtCore -I/media/mohan/QtSDK/Desktop/Qt/474/gcc/include/QtGui -I/media/mohan/QtSDK/Desktop/Qt/474/gcc/include -I. -I. -I/usr/java/jdk1.6.0_33/include/ -I/usr/java/jdk1.6.0_33/include/linux/

[mohan@mohan mohan]$  g++ -shared mohan.o mohan_wrap.o -o libmohan.so
[mohan@mohan mohan]$ javac runme.java
[mohan@mohan mohan]$ java -Djava.library.path=. runme
.
java: symbol lookup error: /home/mohan/Desktop/mohan/libmohan.so: undefined symbol: _ZN12QApplicationC1ERiPPci

_ZN12QApplicationC1ERiPPci -> **QApplication**

Upvotes: 2

Views: 3191

Answers (1)

Martin Beckett
Martin Beckett

Reputation: 96109

QtMain and QtCore are almost always required along with QtGui for gui apps

Upvotes: 4

Related Questions