Github /usr/bin/ld: cannot find -lpcap: No such file or directory

123 Views Asked by At

I have a small rust project in Github and I added a rust.yml file for the actions to build the project and run the tests automatically.

The build crashes while Compiling libc v0.2.153 with the following note:

/usr/bin/ld: cannot find -lpcap: No such file or directory

collect2: error: ld returned 1 exit status

The yml file I'm using for the actions is the basic rust one that Github provides

name: Rust

on:
  push:
    branches: [ "master" ]
  pull_request:
    branches: [ "master" ]

env:
  CARGO_TERM_COLOR: always

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v3
    - name: Build
      run: cargo build --verbose
    - name: Run tests
      run: cargo test --verbose

Do I need to add some libraries or paths to the file?

1

There are 1 best solutions below

0
Sergio García On BEST ANSWER

I solved the issue by simply installing the library.

Just added this to the jobs build section of the YAML file before the build:

    - name: Install libpcap
      run: sudo apt-get update && sudo apt-get install -y libpcap-dev