Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ and Java GUI linkage through SWIG

Tags:

java

c++

cmake

swig

I am trying to include a computational chemistry/physics visualizer known as Avogadro (1) inside of my jTabbedPane project. I used QT Jambi (1) to create a JUI (Java GUI) out of Avogadro's UI in Eclipse. I was successful in that attempt, but the GUI was (obviously functionless) upon running.

In short, the complication here is me trying to access the C++ libraries of a massive project that only has the ability to compile with CMake (Importing into Eclipse was not successful). To make it a bit worse, all I believe I need to interface with is a .cpp file that regulates the GUI and links it to the rest of the project, thus providing functionality. I plan to use SWIG to interface with the functions in the aforementioned cpp file and I plan for the interface to work with the C++ library to add functionality to the Java GUI.

Any thoughts on how I could do this? Do I need to SWIG the entire project?

like image 333
Mjones8323 Avatar asked Jan 19 '26 16:01

Mjones8323


1 Answers

It looks like Avogadro is open source. Therefore, you can download the source code and SWIG the entire project. This will give you the same classes in Java as you would have in C++.

If you only want a subset of Avogadro's functionality, I would suggest creating a simple bridge class in C++. This bridge class, with possibly other helper classes, could then be SWIGed. Your Java would now use the bridge class to execute the Avogadro library.

like image 129
Brant Olsen Avatar answered Jan 21 '26 05:01

Brant Olsen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!