PRBEM / IRBEM

IRBEM-LIB provides routines to compute magnetic coordinates for any location in the Earth's magnetic field, to perform coordinate conversions, to evaluate geophysics/space-physics models, and to propagate orbits in time.
https://prbem.github.io/IRBEM/
Other
33 stars 14 forks source link

matlab searches for onera_desp_lib.so #30

Closed xandrd closed 2 years ago

xandrd commented 2 years ago

I just installed the library on Ubuntu:

sudo apt install gfortran
make OS=linux64 ENV=gfortran64 all
make OS=linux64 ENV=gfortran64 install

My issue is the matlab filed to load the library:

>> onera_desp_lib_load()
Error using onera_desp_lib_load (line 54)
libfile onera_desp_lib.so not found

The workaround is the create a symbolic link in the IRBEM/matlab folder: ln -s ../libirbem.so ./onera_desp_lib.so

The make file does not create a shared library in matlab folder, but it should according to https://github.com/PRBEM/IRBEM/blob/main/matlab/README.TXT

Potential solution

Create a copy of $(LIB_NAME) in the matlab folder

OS, IRBEM version, and compiler version information:

Ubuntu 20.04.4 LTS IRBEM commit: 1ceaca6 MATLAB Version: 9.11.0.1873467 (R2021b) Update 3

mshumko commented 2 years ago

Hi @xandrd, I have not developed in Matlab in years but I hacked together an untested solution. I modified the Matlab wrapper to load libirbem.so (or dll) shared object file. This branch contains the fix. Can you clone it and try it out? You don't need to compile IRBEM again for this test---just copy libirbem.so into the new IRBEM directory and run onera_desp_lib_load().

If this works, I will submit this as a PR. @tpoiii, when I get to that stage, can you review my changes to your wrapper?

xandrd commented 2 years ago

Hi @mshumko, yes I also though about this as a solution. If you what I can double check whether the library only loads by onera_desp_lib_load() or not.

However, in matlab you specify the path where to find the wrapper functions. The library is searched in the same folder. So the Makefile has to copy the library into matlab folder, e.g.: @install $(LIB_NAME) $(INSTALLDIR)/matlab/$(INSTALL_LIB_NAME)

I'm not familiar with @install directive. But if we can copy a second instance of the library it would solve the problem.

I believe, this was an original approach as the README suggested:

The IRBEM compile scripts will create the shared library file for use with IDL or Matlab. A copy of the shared library is created in the "matlab" subdirectory, and is given a name "onera_desp_lib.dll" or "onera_desp_lib.so" depending on the platform.

tpoiii commented 2 years ago

Sasha’s intuition is correct. All onera_desplib*.m routines load the library by calling onera_desp_lib_load. That’s the only place you should have to change the name.

Or you can use the Makefile to make a copy in the matlab folder with the old dll/so name.

-paul

Paul O’Brien, PhD Space Sciences Department – Chantilly The Aerospace Corporation

A101/N5228 571-304-7683 SECURE: 894-7683

Mail Stop: CH1/515 14301 SullyField Circle, Unit C, Chantilly, VA 20151-1622

From: Alexander Drozdov @.> Sent: Tuesday, March 22, 2022 2:31 PM To: PRBEM/IRBEM @.> Cc: T Paul O'Brien @.>; Mention @.> Subject: Re: [PRBEM/IRBEM] matlab searches for onera_desp_lib.so (Issue #30)

Hi @mshumkohttps://github.com/mshumko, yes I also though about this as a solution. If you what I can double check whether the library only loads by onera_desp_lib_load() or not.

However, in matlab you specify the path where to find the wrapper functions. The library is searched in the same folder. So the Makefile has to copy the library into matlab folder, e.g.: @install $(LIB_NAME) $(INSTALLDIR)/matlab/$(INSTALL_LIB_NAME)

I'm not familiar with @install directive. But if we can copy a second instance of the library it would solve the problem.

I believe, this was an original approach as the READMEhttps://github.com/PRBEM/IRBEM/blob/main/matlab/README.TXT suggested:

The IRBEM compile scripts will create the shared library file for use with IDL or Matlab. A copy of the shared library is created in the "matlab" subdirectory, and is given a name "onera_desp_lib.dll" or "onera_desp_lib.so" depending on the platform.

— Reply to this email directly, view it on GitHubhttps://github.com/PRBEM/IRBEM/issues/30#issuecomment-1075485006, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ASQUTRZZSBBM62NG6MT6LYLVBIGXNANCNFSM5RJJ6JCQ. You are receiving this because you were mentioned.Message ID: @.**@.>>

xandrd commented 2 years ago

To make IRBEM a friend of MATLAB the following steps are needed: