[dm-devel] libmpathpersist: Getting undefined symbol during compilation

Benjamin Marzinski bmarzins at redhat.com
Wed Mar 23 22:24:47 UTC 2022


On Sat, Mar 19, 2022 at 08:57:08PM +0530, boli sudha wrote:
> Hi,
> 
> I found this mail Id on the Git page, I never used libmpathpersist or
> libmulitpath.
> One of our applications is using these libraries. Compilation was working
> fine on RedHat 7. I am trying to port our application to Redhat 8. During
> linking I am getting the following error. Can you please help me?
> 
> /usr/lib64/libmpathpersist.so: undefined reference to `put_multipath_config'
> /usr/lib64/libmpathpersist.so: undefined reference to `get_multipath_config'
> /usr/lib64/libmultipath.so: undefined reference to `udev'
> collect2: error: ld returned 1 exit status
> 
> These symbols were not present in the RedHat 7 version of libraries.
> 
> On RedHat 8, these symbols were undefined, I downloaded the git code,
> compiled, and observed that these symbols are defined in binaries, not
> libraries.
> 
> I also tried to remove these libraries from linker command, but so many
> symbols are missing.

Using libmpathpersist is kind of tricky. Later version of
device-mapper-multipath clean this up. But for the version in RHEL-8,
your binary needs to specify some things to work with libmpathpersist.

If your program is single threaded, then you should add something like
(pulled from mpathpersist/main.c):

======================
int logsink = 0;		/* or -1 */
struct config *multipath_conf;

struct config *get_multipath_config(void)
{
	return multipath_conf;
}

void put_multipath_config(__attribute__((unused)) void * arg)
{
	/* Noop for now */
}

void rcu_register_thread_memb(void) {}

void rcu_unregister_thread_memb(void) {}

struct udev *udev;
=====================

If you don't call all the mpathpersist commands with verbose = -1,
the library can log errors. Setting logsink to 0 will log them with a
timestamp. setting it to -1 will not add the timestamp.

Your main funciton also needs to set up these variables. It should
include something like (again pulled from mpathpersist/main.c):

====================
udev = udev_new();
multipath_conf = mpath_lib_init();	
====================

Both of these functions can return NULL on error.

Let me know if that helps.

-Ben

> --
> dm-devel mailing list
> dm-devel at redhat.com
> https://listman.redhat.com/mailman/listinfo/dm-devel



More information about the dm-devel mailing list