iovisor / iovisor/bcc

build failed with using bcc for my c++ applications

Open
#2,345 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
22.7k
Forks
4.1k
Avg merge
10d 4h
Merged PRs (30d)
3

Description

hi, all

I have a c++ application using bcc, but have several errors:

Here is what I did (Ubuntu 16.04, bcc version 0.3.0-fd716dca):

(1) Build bcc from source, by following this [link](https://github.com/iovisor/bcc/blob/master/INSTALL.md#debian---source). After it is successfully installed, I can find the head file at here ` /usr/include/bcc/`

(2) For my c++ application, I include the head file as `#include `.

(3) Compile with g++, and get following errors:

```
In file included from /usr/include/bcc/BPF.h:25,
from bpf_trace.hpp:10:
/usr/include/bcc/BPFTable.h: In constructor ‘ebpf::BPFArrayTable::BPFArrayTable(const ebpf::TableDesc&)’:
/usr/include/bcc/BPFTable.h:127:22: error: ‘BPF_MAP_TYPE_PERCPU_ARRAY’ was not declared in this scope
desc.type != BPF_MAP_TYPE_PERCPU_ARRAY)
^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/bcc/BPFTable.h:127:22: note: suggested alternative: ‘BPF_MAP_TYPE_PROG_ARRAY’
desc.type != BPF_MAP_TYPE_PERCPU_ARRAY)
^~~~~~~~~~~~~~~~~~~~~~~~~
BPF_MAP_TYPE_PROG_ARRAY
/usr/include/bcc/BPFTable.h: In constructor ‘ebpf::BPFPercpuArrayTable::BPFPercpuArrayTable(const ebpf::TableDesc&)’:
/usr/include/bcc/BPFTable.h:168:22: error: ‘BPF_MAP_TYPE_PERCPU_ARRAY’ was not declared in this scope
if (desc.type != BPF_MAP_TYPE_PERCPU_ARRAY)
^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/bcc/BPFTable.h:168:22: note: suggested alternative: ‘BPF_MAP_TYPE_PROG_ARRAY’
if (desc.type != BPF_MAP_TYPE_PERCPU_ARRAY)
^~~~~~~~~~~~~~~~~~~~~~~~~
BPF_MAP_TYPE_PROG_ARRAY
/usr/include/bcc/BPFTable.h: In constructor ‘ebpf::BPFHashTable::BPFHashTable(const ebpf::TableDesc&)’:
/usr/include/bcc/BPFTable.h:199:22: error: ‘BPF_MAP_TYPE_PERCPU_HASH’ was not declared in this scope
desc.type != BPF_MAP_TYPE_PERCPU_HASH &&
^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/bcc/BPFTable.h:199:22: note: suggested alternative: ‘BPF_MAP_TYPE_HASH’
desc.type != BPF_MAP_TYPE_PERCPU_HASH &&
^~~~~~~~~~~~~~~~~~~~~~~~
BPF_MAP_TYPE_HASH
/usr/include/bcc/BPFTable.h:200:22: error: ‘BPF_MAP_TYPE_LRU_HASH’ was not declared in this scope
desc.type != BPF_MAP_TYPE_LRU_HASH &&
^~~~~~~~~~~~~~~~~~~~~
/usr/include/bcc/BPFTable.h:200:22: note: suggested alternative: ‘BPF_MAP_TYPE_HASH’
desc.type != BPF_MAP_TYPE_LRU_HASH &&
^~~~~~~~~~~~~~~~~~~~~
BPF_MAP_TYPE_HASH
/usr/include/bcc/BPFTable.h:201:22: error: ‘BPF_MAP_TYPE_LRU_PERCPU_HASH’ was not declared in this scope
desc.type != BPF_MAP_TYPE_LRU_PERCPU_HASH)
```

I think the error comes from here:

```
auto table=
bpf->get_hash_table("lat").get_table_offline();
```

(4) I also used the same way to compile the c++ example in the example folder (one line change to the source code, `#include -> #include`) and got the same error .

Any ideas ?? Appreciate for the help.

The second question, Do I need to link to bcc, though currently, it is just compiling error ?

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the build on Ubuntu 16.04 with bcc version 0.3.0-fd716dca, following the Debian source steps in INSTALL.md. Inspect the installed /usr/include/bcc/BPF.h and BPFTable.h and compare them with the C++ example that was modified to include bcc/BPF.h; done means determining the cause of the missing map constants and the required build or linking setup.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, linux
Domain
build-system, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.