Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: /lib/x86_64-linux-gnu/libbcc.so.0: undefined symbol: bpf_module_create_b #4583

Closed
AkaCoder404 opened this issue Apr 21, 2023 · 17 comments

Comments

@AkaCoder404
Copy link

Referring to this #4114, the solution is to use python3 instead of python (2.7), however I have followed the instructions and still getting an error, how do I solve this?

>>> import bcc
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/bcc/__init__.py", line 26, in <module>
    from .libbcc import lib, bcc_symbol, bcc_symbol_option, bcc_stacktrace_build_id, _SYM_CB_TYPE
  File "/usr/lib/python3/dist-packages/bcc/libbcc.py", line 20, in <module>
    lib.bpf_module_create_b.restype = ct.c_void_p
  File "/usr/lib/python3.8/ctypes/__init__.py", line 386, in __getattr__
    func = self.__getitem__(name)
  File "/usr/lib/python3.8/ctypes/__init__.py", line 391, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: /lib/x86_64-linux-gnu/libbcc.so.0: undefined symbol: bpf_module_create_b

I am running

$ python3 --version
Python 3.8.10

on machine

Linux XXX 5.15.0-69-generic #76~20.04.1-Ubuntu SMP Mon Mar 20 15:54:19 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

I have compiled with LLVM_ROOT=/usr/lib/llvm-12.

@jfernandez
Copy link

I'm having the same error. Also using python3 and compiled from source using the Ubuntu instructions.

@AkaCoder404
Copy link
Author

@jfernandez, I could not fix this error (I did not want to keep debugging so I used docker instead. I wrote a simple docker file and tried compiling from source in the docker file.

FROM ubuntu:20.04

RUN apt-get update

RUN apt-get install -y zip unzip

# Install recommended tools
RUN apt-get install -y arping netperf iperf3

# Install BCC dependencies for Ubuntu 20.04
RUN DEBIAN_FRONTEND=noninteractive \
  TZ=Asia/Singapore \ 
  apt-get install -y \
  bison build-essential cmake flex git libedit-dev \
  libllvm12 llvm-12-dev libclang-12-dev python zlib1g-dev libelf-dev libfl-dev python3-setuptools

# Install LuaJIT for BCC 
RUN apt-get -y install luajit luajit-5.1-dev

RUN apt-get -y install liblzma-dev

# Build BCC from source
RUN git clone https://github.com/iovisor/bcc.git
RUN mkdir bcc/build && cd bcc/build && \ 
      cmake .. && \
      make install && \
      cmake -DPYTHON_CMD=python3 .. && \ 
      cd src/python/ && \
      make && \
      make install && \
      cd ../..

# Kernel Headers
RUN apt-get install linux-headers-$(uname -r)


# Set working directory
WORKDIR /src

with a base image as ubuntu:20.04 but I think you can use your own preference. Then I built it with docker build --no-cache -t docker-ebpf:v1 . and ran it with

docker run --privileged \
    --name docker-ebpf \
    --net=host \
    -v /sys/kernel/debug:/sys/kernel/debug:rw \
    -v /lib/modules/:/lib/modules:ro \
    -v /etc/localtime:/etc/localtime:ro \
    -v /pathtosrcfiles:/src \ 
    -t -i docker-ebpf:v1 /bin/bash

This still does not solve the issue above, but I was able to successfully run the helloworld.py test case

@chenhengqi
Copy link
Collaborator

bpf_module_create_b is gone. Try build from source and reinstall.

@AkaCoder404
Copy link
Author

@chenhengqi I have tried multiple times for installing from source, and always get stuck on this error. Perhaps is there a way to completely uninstall/reinstall process that I am missing?

@chenhengqi
Copy link
Collaborator

Can you remove the old libbcc.so manually ?

@AkaCoder404
Copy link
Author

I have tried, does not solve the problem.

@jasneetsinghwahan
Copy link

@chenhengqi please help

$ sudo apt-get install bpfcc-tools linux-headers-$(uname -r) 
$ sudo apt-get update 
$ sudo apt-get install -y llvm clang 
$ sudo apt install -y zip bison build-essential cmake flex git libedit-dev \ 
  libllvm12 llvm-12-dev libclang-12-dev python zlib1g-dev libelf-dev libfl-dev python3-setuptools \ 
  liblzma-dev arping netperf iperf 
$ mkdir bcc/build; cd bcc/build 
$ sudo apt-get install libclang-10-dev 
$ cmake ..
changed /bcc/cmake/clang_libs.cmake and appended Polly and PollyISL
list(APPEND clang_libs 
${libclangParse} 
${libclangSema} 
${libclangCodeGen} 
${libclangAnalysis} 
${libclangRewrite} 
${libclangEdit} 
${libclangAST} 
${libclangLex} 
Polly 
PollyISL) 
$ make 
$ sudo make install 
$ cmake -DPYTHON_CMD=python3 .. # build python3 binding
$ pushd src/python/
$ make
$ sudo make install
$ popd
$ find /usr/lib -name bcc
$ sudo python3 hellow_world.py

Traceback (most recent call last):
  File "hello_world.py", line 9, in <module>
    from bcc import BPF
  File "/usr/lib/python3/dist-packages/bcc/__init__.py", line 26, in <module>
    from .libbcc import lib, bcc_symbol, bcc_symbol_option, bcc_stacktrace_build_id, _SYM_CB_TYPE
  File "/usr/lib/python3/dist-packages/bcc/libbcc.py", line 20, in <module>
    lib.bpf_module_create_b.restype = ct.c_void_p
  File "/usr/lib/python3.8/ctypes/__init__.py", line 386, in __getattr__
    func = self.__getitem__(name)
  File "/usr/lib/python3.8/ctypes/__init__.py", line 391, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: /lib/x86_64-linux-gnu/libbcc.so.0: undefined symbol: bpf_module_create_b

@chenhengqi
Copy link
Collaborator

Probably, /usr/lib/python3/dist-packages/bcc is a leftover of a previous BCC installation. Can you remove it and install BCC again ?

@jasneetsinghwahan
Copy link

thanks, it worked

@AkaCoder404
Copy link
Author

This works, thanks!

@ulugbek5609
Copy link

Worked for me as well. Thank you very much.

@pankul-zhang
Copy link

worked for me too thanks.

@coco21
Copy link

coco21 commented Sep 22, 2023

Worked for me too, thanks!

@0mobb0
Copy link

0mobb0 commented Oct 9, 2023

Probably, /usr/lib/python3/dist-packages/bcc is a leftover of a previous BCC installation. Can you remove it and install BCC again ?

Thanks!That worked for me as well

@shyhc
Copy link

shyhc commented Feb 22, 2024

Worked for me too, thanks!

1 similar comment
@cassini-w
Copy link

Worked for me too, thanks!

@AgnesWickfield
Copy link

Probably, /usr/lib/python3/dist-packages/bcc is a leftover of a previous BCC installation. Can you remove it and install BCC again ?

Thanks, you've been a great help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests