Forum

Author Topic: Metashape Java API running on UBUNTU  (Read 2432 times)

SDUIVM

  • Newbie
  • *
  • Posts: 7
    • View Profile
Metashape Java API running on UBUNTU
« on: September 07, 2022, 10:35:51 AM »
Hi everyone,

Thank you for your amazing software.

I am running metashape on Ubuntu.
I am using the 1.8.4 version, I removed the libgmp.10.so file and everything works find when running metashape in GUI mode.

Now I am trying to use the Java API with maven using the following github repo : https://github.com/jseinturier/metashape-java-maven

With version 1.8.2 everything is working except that exporting points is not working as mentioned in this thread : https://www.agisoft.com/forum/index.php?topic=14336.0
So I need to stick with the 1.8.4 version.

I get the following error with 1.8.4 :
SEVERE: Cannot load Metashape library from /tmp/libmetashape.so: /tmp/libmetashape.so: /lib/x86_64-linux-gnu/libgnutls.so.30: undefined symbol: __gmpz_limbs_write
java.lang.UnsatisfiedLinkError: /tmp/libmetashape.so: /lib/x86_64-linux-gnu/libgnutls.so.30: undefined symbol: __gmpz_limbs_write

It is the same tls error produced by the libgmp.10.so file so my guess is : could it be possible that the libmetashape.so used in the Java api was obtained with the wrong gmp version ? I hope its not a stupid guess though.

Thank you very much for your help,

PolarNick

  • Full Member
  • ***
  • Posts: 102
    • View Profile
Re: Metashape Java API running on UBUNTU
« Reply #1 on: September 07, 2022, 12:06:32 PM »
Hi,

About libgmp.10.so error "undefined symbol: __gmpz_limbs_write":

1) It can be fixed like you described with deletion of libgmp.10.so, in fact in Metashape 1.8.4 it is so by default - this file was renamed to libgmp.10.so.compat, so that it is ignored (but can be manually renamed back to libgmp.10.so to be used again - it is useful on old Linux distributions with old system libgmp.10.so)

2) Alternatively it can be fixed with forced pre-loading of system libgmp.10.so before Metashape launch - then Metashape will ignore its bundled libgmp.10.so even if it is presented with such name in metashape/lib. You can do it with LD_PRELOAD='/usr/lib/x86_64-linux-gnu/libgmp.so.10' /path/to/metashape.sh

About Java API:

3) Basically there are everything the same, you can see that in metashape-java-api-1.8.4.zip there are libgmp.so.10.compat in metashape-java-api-1.8.4/jniLibs/linux64/, so if you use official Java API library - everything should work

4) It seems that this change was properly adapted by maven artifact mantainer - https://github.com/jseinturier/metashape-java-maven/commit/d114ea49bf3c09efdc4be1a71e9226d7b11946b2#diff-9f4fb1e1e4ca8b6aa4584334671cb5b949abfc96114847d57383e2c04f0502a6 (libgmp.10.so was renamed to libgmp.10.so.compat) - so may be you use old artifact?

5) Also you can workaround this problem for older versions by launching your java application (for GUI version it works too) with environment variable that will force loading of system libgmp: LD_PRELOAD='/usr/lib/x86_64-linux-gnu/libgmp.so.10'
« Last Edit: September 07, 2022, 12:09:57 PM by PolarNick »

SDUIVM

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Metashape Java API running on UBUNTU
« Reply #2 on: September 07, 2022, 12:15:42 PM »
Great trick it works with export LD_PRELOAD=/pathtosystemlibgmp/
before launching the maven project.

Thank you !