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

编译不成功(error: call of overloaded ‘vector(nlohmann::basic_json<>&)’ is ambiguous) #22

Open
liansh2002 opened this issue Sep 8, 2020 · 3 comments

Comments

@liansh2002
Copy link

想在Raspberry pi上使用,所以先试下在PC上自行编译安装,但编译不成功。
编译环境:
x86_64,Debian 10,gcc (Debian 8.3.0-6),nlohmann-json3-dev/now 3.9.0-1 all,cmake version 3.18.2

错误信息
[ 40%] Building CXX object src/CMakeFiles/main.dir/config.cpp.o /usr/local/etc/app/cgproxy/src/config.cpp: In member function ‘bool CGPROXY::CONFIG::Config::validateJsonStr(std::__cxx11::string)’: /usr/local/etc/app/cgproxy/src/config.cpp:127:60: error: call of overloaded ‘vector(nlohmann::basic_json<>&)’ is ambiguous if (value.is_array() && !validCgroup((vector<string>)value)) status = false; ^~~~~ In file included from /usr/include/c++/8/vector:64, from /usr/local/etc/app/cgproxy/build/src/common.h:7, from /usr/local/etc/app/cgproxy/src/config.h:3, from /usr/local/etc/app/cgproxy/src/config.cpp:1: /usr/include/c++/8/bits/stl_vector.h:515:7: note: candidate: ‘std::vector<_Tp, _Alloc>::vector(std::initializer_list<_Tp>, const allocator_type&) [with _Tp = std::__cxx11::basic_string<char>; _Alloc = std::allocator<std::__cxx11::basic_string<char> >; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::__cxx11::basic_string<char> >]’ vector(initializer_list<value_type> __l, ^~~~~~ /usr/include/c++/8/bits/stl_vector.h:476:7: note: candidate: ‘std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&) [with _Tp = std::__cxx11::basic_string<char>; _Alloc = std::allocator<std::__cxx11::basic_string<char> >]’ vector(vector&& __x) noexcept ^~~~~~ /usr/include/c++/8/bits/stl_vector.h:458:7: note: candidate: ‘std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = std::__cxx11::basic_string<char>; _Alloc = std::allocator<std::__cxx11::basic_string<char> >]’ vector(const vector& __x) ^~~~~~ /usr/include/c++/8/bits/stl_vector.h:415:7: note: candidate: ‘std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>::size_type, const allocator_type&) [with _Tp = std::__cxx11::basic_string<char>; _Alloc = std::allocator<std::__cxx11::basic_string<char> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::__cxx11::basic_string<char> >]’ vector(size_type __n, const allocator_type& __a = allocator_type()) ^~~~~~ make[2]: *** [src/CMakeFiles/main.dir/build.make:108: src/CMakeFiles/main.dir/config.cpp.o] Error 1 make[1]: *** [CMakeFiles/Makefile2:184: src/CMakeFiles/main.dir/all] Error 2 make: *** [Makefile:171: all] Error 2

@black-desk
Copy link

the same problem here

@thetrashyNoob27
Copy link

bad news first,author does not provide armhf version execsnoop-kernel, im trying to figure it out. currnetly cant compile on 32bit version raspbian.
64bit ubuntu, gcc10.2.0, raspberry 4b compiled, working fine.

problem No.1 error: call of overloaded ‘vector(nlohmann::basic_json<>&)’ is ambiguous):
change src/config.cpp line127:
if (value.is_array() && !validCgroup((vector<string>)value)) status = false;//noting wrong,gcc8 problem
to
if (value.is_array() && !validCgroup(value.get<std::vector<string>>())) status = false; //solution

then problem No.2:socket_server.cpp:(.text+0xf8): undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'
seems gcc8 have some issue with std::filesystem,so i did this:

namespace CGPROXY::SOCKET {
bool isFileExist(const char* path)//add this function to check if file exist
{
  struct stat buffer;
  return (stat(path,&buffer)==0);
}

void SocketServer::socketListening(function<int(char *)> callback, promise<void> status) {
  debug("starting socket listening");
  sfd = socket(AF_UNIX, SOCK_STREAM, 0);

  //if (fs::exists(SOCKET_PATH) && unlink(SOCKET_PATH) == -1)//orignal,have issue with gcc8
  if (isFileExist(SOCKET_PATH) && unlink(SOCKET_PATH) == -1)
  {
    error("%s exist, and can't unlink", SOCKET_PATH);
    return;
  }

problem No.3:execsnoop_share.cpp:55:29: error: ‘execsnoop_kern__open_and_load’ was not declared in this scope
havent figure it out yet

@maomaochong199
Copy link

maomaochong199 commented Nov 7, 2021

我的arm64机找不到libbpf,怎么办
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
LIBBPF
linked by target "execsnoop" in directory /home/mmc199/cgproxy-master/execsnoop-kernel

-- Configuring incomplete, errors occurred!
See also "/home/mmc199/cgproxy-master/build/CMakeFiles/CMakeOutput.log".

https://www.oracle.com/cn/cloud/free/

http://cdimage.ubuntu.com/ubuntukylin/focal/daily-live/current/focal-desktop-arm64.iso

=================================================================
编译好了一个优麒麟用的,使用时还要自己下载安装所需的libbpf
不然systemctl status cgproxy.service 会看见错误

info: socketserver thread started
info: loading /usr/lib/aarch64-linux-gnu/cgproxy/libexecsnoop.so
error: dlopen /usr/lib/aarch64-linux-gnu/cgproxy/libexecsnoop.so failed: libbpf.so.0:
cannot open shared object file: No such file or directory
error: execsnoop not ready to start, maybe missing libbpf

cgproxy_0.19_UbuntuKylin20.04arm64.deb.zip
libbpf要从Ubuntu的源自己下载
http://ports.ubuntu.com/ubuntu-ports/ubuntu-ports/pool/universe/libb/libbpf/
dpkg -i *.deb
安装libbpf0_0.1.0-1_arm64.deb 、 libbpf-dev_0.1.0-1_arm64.deb 两个文件。

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

4 participants