How to compile liblxc (lxc itself compiles OK)

Hi all,
I need some help compiling ‘liblxc’ for my troubleshooting.

Background:
I am having issue with lxc in OpenMandriva. If I try to create a container, I get error as below.

[sv@openmandriva-x8664 ~]$ lxc-create -n test -t download
lxc-create: symbol lookup error: lxc-create: undefined symbol: lxc_is_valid_storage_type

I have gone through lxc introduction, Stéphane Graber’s blog series, Debian and Arch wikis for lxc. While I do not understand everythng, I do have working lxc on Arch and MX Linux. So, my configurations are OK (to the best of my knowledge). The above error is specific to current distro and I decided to compile the software to test and if successful, raise a ticket with the distribution to fix the package.

While I was able to compile lxc, it did not fix the above issue.

Although I could not get any exact match for the error lxc_is_valid_storage_type, I have seen some errors related to various undefined symbol. On one such discussion, issue #3266, @stgraber suggests (re)compiling liblxc.

When I checked back, there was indeed no liblxc.so.1 after my compile of lxc (inside a docker). And if I tried lxc-ls --version it shows error saying something like, ‘unable to find shared library liblxc.so.1’.

Add to this, I saw a peculiarity in lxc’s version reporting in my distro. dnf info lxc would report version 6.0.4 while lxc-info --version reports version 4.0.6. On further check found the lib64lxc1 package is at version 4.0.6 meaning the version reported by binaries is from library file?

[sv@openmandriva-x8664 ~]$ dnf info lxc
Last metadata expiration check: 0:48:24 ago on Friday 27 June 2025 10:52:02 PM.
Installed Packages
Name         : lxc
Version      : 6.0.4
Release      : 1
Architecture : x86_64
Size         : 6.8 M
Source       : lxc-6.0.4-1.src.rpm
Repository   : @System
From repo    : rock-x86_64
Summary      : Linux Containers
URL          : https://lxc.sourceforge.net
License      : LGPLv2
Description  : The package "lxc" provides the command lines to create and manage
             : containers.  It contains a full featured container with the isolation
             : / virtualization of the pids, the ipc, the utsname, the mount points,
             : /proc, /sys, the network and it takes into account the control groups.
             : It is very light, flexible, and provides a set of tools around the
             : container like the monitoring with asynchronous events notification,
             : or the freeze of the container. This package is useful to create
             : Virtual Private Server, or to run isolated applications like bash or
             : sshd.

[sv@openmandriva-x8664 ~]$ lxc-info --version
4.0.6
[sv@openmandriva-x8664 ~]$ dnf info lib64lxc1
Last metadata expiration check: 0:48:40 ago on Friday 27 June 2025 10:52:02 PM.
Installed Packages
Name         : lib64lxc1
Epoch        : 1
Version      : 4.0.6
Release      : 2
Architecture : x86_64
Size         : 815 k
Source       : lxc-4.0.6-2.src.rpm
Repository   : @System
From repo    : rock-x86_64
Summary      : Library for LXC
URL          : http://lxc.sourceforge.net
License      : LGPLv2
Description  : Library for the Linux Kernel Containers.

So now, back to my request, :grinning: how to compile ‘liblxc’? I do not see it in the lxc repo whereas in the discussion I referred above, @stgraber says,

liblxc (liblxc.so , liblxc.so.1 ) comes from this repository…

Please guide me on this.

The lxc repository is what builds liblxc.so.1. You probably want to look around at what’s in your build directory.

Ah…the build directory does have liblxc.so* files. It was my mistake; I compiled with prefix ‘/usr/local’ and these library files were under ‘/usr/local/lib64’. The binary was looking inside ‘/usr/lib64’, which was empty. On rebuilding with prefix ‘/usr’, lxc is reporting correct version and running fine too. Thank you so very much @stgraber.