问题
I am working on a project that uses MPI to create parallel processes, each process uses dlopen() to load a module that's been build as a shared object library. One of the modules that I'm writing uses a 3rd party library (HDF). When I run the program, dlopen throws an error: dlopen failed: /home/jwomble/QTProjects/SurrogateModule/libsurrogate.so: undefined symbol: H5T_NATIVE_INT32_g
The undefined symbol is in the HDF library. How do I load the symbols from the HDF library?
Currently, my make file looks like this:
CC = mpicc
INCDIR = -I /home/jwomble/QTProjects/STARExecutive/src/star_comm \
-I /home/jwomble/QTProjects/STARExecutive/src/executive \
-I /home/jwomble/QTProjects/Star \
-I ./phdf/include
CFLAGS = -Wall -rdynamic -g -fPIC $(INCDIR)
all: libsurrogate.so
libsurrogate.so: SurrogateModule.o
$(CC) -shared --export-dynamic -o $@ $<
SurrogateModule.o: SurrogateModule.c
$(CC) $(CFLAGS) -lhdf5 -c $<
Thanks!
回答1:
You are not actually linking against hdf5. The -l
Flag is useless when used together with -c
.
Moving -lhdf5
upt to the linking of libsurrogate.so should fix the problem.
来源:https://stackoverflow.com/questions/10128366/shared-object-library-and-mpi