X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 24 Jan 2022 09:55 AM by  Mark Baumgartner
calling IDL system routines from DLM
 0 Replies
Sort:
You are not authorized to post a reply.
Author Messages

Mark Baumgartner



New Member


Posts:
New Member


--
24 Jan 2022 09:55 AM
    I would dearly love to be able to access the NetCDF routines in the NCDF DLM from my own C code packaged in my own DLM. This is a specific case of the more general problem of needing to access IDL system routines from within a user-written DLM. Is there an interface for this? One option is to use IDL_ExecuteStr(), but this appears to be discouraged in the IDL documentation (and is really inefficient). I had thought that defining an external function in my DLM code as follows:

    extern IDL_VPTR IDL_CDECL IDL_ncdf_open(int argc, IDL_VPTR argv[], char *argk);

    and then calling it simply as

    IDL_VPTR rv;
    rv = IDL_ncdf_open(out_argc, out_argv, out_argk);

    with appropriately assigned out_argc, out_argv and out_argk variables would be sufficient, but the linker can't find the symbol _IDL_ncdf_open in /Applications/harris/idl/bin/bin.darwin.x86_64/idl_netcdf.so. The error my DLM throws is as follows:

    dyld: lazy symbol binding failed: Symbol not found: _IDL_ncdf_open
    Referenced from: /Users/Mark/Projects/Detectors/lfdcs/idl_dlm/native_idl_netcdf_test_dlm.so
    Expected in: flat namespace

    I have even tried opening idl_netcdf.so in my code using dlopen, but the symbol still can't be resolved. The problem appears to be that there is no dynamic symbol table in idl_netcdf.so, so none of the functions therein can be dynamically linked and therefore resolved. Here is the output of nm when looking for the dynamic symbol table:

    % nm -D idl_netcdf.so
    /Library/Developer/CommandLineTools/usr/bin/nm: idl_netcdf.so: File format has no dynamic symbol table.

    I can see that the normal symbol table has the symbols I'm looking for, but they are not available dynamically, so cannot be resolved and used at runtime:

    % nm idl_netcdf.so | grep ncdf_open
    0000000000001650 t _IDL_ncdf_open
    0000000000809960 b _IDL_ncdf_open.do_write
    0000000000809964 b _IDL_ncdf_open.dont_write
    0000000000775d50 d _IDL_ncdf_open.keywords

    It seems this issue has been around for a long time (here's a post with the same question from 1999: https://pages.physics.wisc.edu/~craigm/idl/archive/msg00589.html), but I have yet to find a solution. Without being able to access the NCDF DLM, I'm forced to statically link the NetCDF library and all of its dependencies, which is a real challenge when distributing my software.

    Is there a more elegant way to do this than IDL_ExecuteStr()? Thanks for any help.

    Mark Baumgartner
    Woods Hole Oceanographic Institution
    You are not authorized to post a reply.