Lua cannot open libcairo with error "undefined symbol: luaopen_libcairo"

780 Views Asked by At

I am trying to configure conky to work with cairo, I added "require 'libcairo'" to the top of the default .conkyrc to make sure it would load, however, when I run conky, it gives me this error:

error loading module 'libcairo' from file './libcairo.so':
./libcairo.so: undefined symbol: luaopen_libcairo

I have been browsing other related questions, and most suggest that the lua version and cairo library are mismatched. I have ensured that i am using Lua 5.3 and i compiled the latest version of Cairo from the tarball on their downloads page (version 1.17.4).

I tried using the Lua interpreter to load the module and determine what was actually causing the error, however when i give it

>require 'libcairo'

it returns the same error.

After purging and reinstalling conky, lua, and libcairo, it still is not working. I do not know where I am going wrong but I would be happy to provide any info the reader will need to help.

EDIT: I should add that I am using Arch with KDE5

2

There are 2 best solutions below

1
Doyousketch2 On
sudo apt install libcairo2-dev

You've probably done these following commands, but the difference is in the cmake.
Just include -D then the name of the flag you wish to use.

mkdir build  
cd build  
cmake -DBUILD_LUA_CAIRO=true ..  
nice make -j$(nproc)  
sudo make install  

https://github.com/brndnmtthws/conky/blob/master/cmake/ConkyBuildOptions.cmake


Cairo possibly needs Pango. I won't say you have to install it, but if the above command doesn't get you where you're going, then I'd look at pango / freetype libs as a possible source as to why.

sudo apt install libpango1.0-dev
cmake -DBUILD_LUA_CAIRO=true -DBUILD_XFT=true ..
0
mok0 On

On Pop!_OS 21.04 (= Ubuntu 20.04 plus some extras) I simply had to install the conky-all package, it uninstalls conky-std which does not work with Cairo.