1

我收到编译错误:error: ‘scmp_filter_ctx’ was not declared in this scope.
我已经声明了一个 seccomp 过滤器。 scmp_filter_ctx ctx;

我已包含该库#include <linux/seccomp.h> 并已libseccomp-dev使用 sudo apt-get install libseccomp-dev.

#include <stdlib.h>
#include <fcntl.h>
#include <sys/shm.h>
#include <unistd.h>
#include <sys/un.h>
#include <sys/wait.h>
#include <linux/seccomp.h>
#include <sys/prctl.h>
#include <sys/types.h>
#include <sys/stat.h>

#include <bits/stdc++.h>

void create_sandbox(){
scmp_filter_ctx ctx;
ctx = seccomp_init(SCMP_ACT_KILL); // default action: kill

seccomp_load(ctx);
}
4

1 回答 1

1

我设法使用以下方法解决了这个错误:

在编译时替换#include <linux/seccomp.h>为and ,使用.#include <seccomp.h>g++ filename.cpp -lseccomp

这对我有用。

于 2019-02-08T08:25:23.633 回答