g++static-librariessilo

g++ static linking problems with silo library


I have some sample code that uses the silo library:

#include <silo.h>
#include <iostream>
int main(int argc, char *argv[])
{
    DBfile *dbfile = NULL;
        /* Open the Silo file */
    dbfile = DBCreate("basic.silo" , DB_CLOBBER, DB_LOCAL,"Comment about the data", DB_HDF5);

    if(dbfile == NULL)
    {
        return -1;
    }
    /* Add other Silo calls here. */
    /* Close the Silo file. */
    DBClose(dbfile);
    return 0;
}

I installed the silo library via macports. The silo port contains:

Port silo contains:
  /opt/local/include/ioperf.h
  /opt/local/include/pmpio.h
  /opt/local/include/silo.h
  /opt/local/include/silo.inc
  /opt/local/lib/libsiloh5.a
  /opt/local/lib/libsiloh5.la
  /opt/local/lib/libsiloh5.settings 

When I attempt to compile my sample code with:

g++ functions.cpp /opt/local/lib/libsiloh5.a 

I get a huge list of errors:

Undefined symbols for architecture x86_64:
  "_H5Aclose", referenced from:
      _db_hdf5_Open in libsiloh5.a(silo_hdf5.o)
      _db_hdf5_Create in libsiloh5.a(silo_hdf5.o)
      _db_hdf5_GetObject in libsiloh5.a(silo_hdf5.o)
      _db_hdf5_InqVarType in libsiloh5.a(silo_hdf5.o)
      _db_hdf5_InqMeshName in libsiloh5.a(silo_hdf5.o)
      _db_hdf5_GetCurve in libsiloh5.a(silo_hdf5.o)
      _db_hdf5_GetCsgmesh in libsiloh5.a(silo_hdf5.o)
      ...
  "_H5Acreate1", referenced from:
      _db_hdf5_Create in libsiloh5.a(silo_hdf5.o)
      _db_hdf5_hdrwr in libsiloh5.a(silo_hdf5.o)
      _db_hdf5_compname in libsiloh5.a(silo_hdf5.o)
  "_H5Aget_type", referenced from:
      _db_hdf5_GetObject in libsiloh5.a(silo_hdf5.o)
      _db_hdf5_GetComponentStuff in libsiloh5.a(silo_hdf5.o)
      _db_hdf5_get_comp_var in libsiloh5.a(silo_hdf5.o)
      _copy_dir in libsiloh5.a(silo_hdf5.o)

This continues for lines and lines...

What am I doing wrong?

Thanks


Solution

  • You need to link in the HDF5 library. Silo sits on top of other low-level storage libraries such as PDB, NetCDF, and HDF5.