LLDB 15 build on Linux cannot find libpython3.11.so.1.0

Hi,

I’m trying to build LLDB from LLVM version 15 on Linux. I’m getting the following errors:

[41/48] Linking CXX executable bin/lldb-vscode
FAILED: bin/lldb-vscode
: && /bin/g++ -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wmisleading-indentation -fdiagnostics-color -ffunction-sections -fdata-sections -Wno-deprecated-declarations -Wno-unknown-pragmas -Wno-strict-aliasing -Wno-stringop-truncation -O3 -DNDEBUG -Wl,-rpath-link,/home/zilonkaj/llvm-project/build/./lib -Wl,–gc-sections tools/lldb/tools/lldb-vscode/CMakeFiles/lldb-vscode.dir/lldb-vscode.cpp.o tools/lldb/tools/lldb-vscode/CMakeFiles/lldb-vscode.dir/BreakpointBase.cpp.o tools/lldb/tools/lldb-vscode/CMakeFiles/lldb-vscode.dir/ExceptionBreakpoint.cpp.o tools/lldb/tools/lldb-vscode/CMakeFiles/lldb-vscode.dir/FifoFiles.cpp.o tools/lldb/tools/lldb-vscode/CMakeFiles/lldb-vscode.dir/FunctionBreakpoint.cpp.o tools/lldb/tools/lldb-vscode/CMakeFiles/lldb-vscode.dir/IOStream.cpp.o tools/lldb/tools/lldb-vscode/CMakeFiles/lldb-vscode.dir/JSONUtils.cpp.o tools/lldb/tools/lldb-vscode/CMakeFiles/lldb-vscode.dir/LLDBUtils.cpp.o tools/lldb/tools/lldb-vscode/CMakeFiles/lldb-vscode.dir/OutputRedirector.cpp.o tools/lldb/tools/lldb-vscode/CMakeFiles/lldb-vscode.dir/ProgressEvent.cpp.o tools/lldb/tools/lldb-vscode/CMakeFiles/lldb-vscode.dir/RunInTerminal.cpp.o tools/lldb/tools/lldb-vscode/CMakeFiles/lldb-vscode.dir/SourceBreakpoint.cpp.o tools/lldb/tools/lldb-vscode/CMakeFiles/lldb-vscode.dir/VSCode.cpp.o -o bin/lldb-vscode -Wl,-rpath,“$ORIGIN/…/lib” lib/libLLVMSupport.a lib/libLLVMOption.a lib/libLLVMSupport.a -lpthread lib/liblldb.so.15.0.0 -lpthread -lrt -ldl -lpthread -lm /usr/lib64/libz.so /usr/lib64/libtinfo.so lib/libLLVMDemangle.a && :
/bin/ld: warning: libpython3.11.so.1.0, needed by lib/liblldb.so.15.0.0, not found (try using -rpath or -rpath-link)
/bin/ld: lib/liblldb.so.15.0.0: undefined reference to PyTuple_SetItem' /bin/ld: lib/liblldb.so.15.0.0: undefined reference to PyObject_GetBuffer’
/bin/ld: lib/liblldb.so.15.0.0: undefined reference to `PyObject_Repr’

I have a few different versions of Python 2 and 3 on my system, so my first thought was that it was grabbing the wrong one. But the build’s CMakeCache.txt shows it’s finding the Python 3.11 install. I tried using -DLLDB_PYTHON_HOME to force it to use the Python 3.11 install in case it was still grabbing the wrong one, but that didn’t help.

Any help here would be appreciated.

The error seems odd to me - you’re building lldb-vscode, but the link is failing because liblldb.so can’t resolve python functions from libpython3.11.so.

My guess is cmake knows where your Python 3.11 is, and the link of liblldb.so worked, but lldb-vscode doesn’t need Python, so the location of libpython3.11.so isn’t on its link line.

Try copying libpython3.11.so.1.0 to your <build>/lib directory. You’ll need it in a place that the loader can find, which your rpath (of $ORIGIN/…/lib) will find in the lib directory next to bin where lldb-vscode is.

If that doesn’t work, set LD_LIBRARY_PATH to point to <python>/lib.

1 Like

Copying libpython3.11.so.1.0 to build/lib did the trick. Thank you! An odd error indeed.