sogou / srpc

RPC framework based on C++ Workflow. Supports SRPC, Baidu bRPC, Tencent tRPC, thrift protocols.
Apache License 2.0
1.94k stars 382 forks source link

problem #297

Closed ChengYe9527 closed 10 months ago

ChengYe9527 commented 1 year ago

i try to use srpc/tools/srpc to make http,but it not work

截屏2023-03-30 14 44 56
ChengYe9527 commented 1 year ago

我应该怎么使用呢

holmes1412 commented 1 year ago

你好,我执行这个命令是没有问题的。猜测是getopt这个函数在不同系统里的返回值不一样,导致非参数的解析也进入了default分支。

麻烦确认下是否使用最新的代码,另外可以告知一下具体的系统等信息吗?

ChengYe9527 commented 1 year ago

是在docker下,ubuntu20.04 从github的srpc页面下载 git clone --recursive https://github.com/sogou/srpc.git cd srpc make 也装了protobuf3.6.1的版本,编译没有报错了

ChengYe9527 commented 1 year ago

是有特定的安装路径吗?

holmes1412 commented 1 year ago

和安装路径没有关系,这个小工具只是做简单的参数解析,还不涉及pb呢。我们也没遇到过这个问题,目前只能是怀疑getopt这个返回值在不同平台下有点不一样,需要等我找到类似的系统复现出来才能确定。

ChengYe9527 commented 1 year ago

tools里面的工具有涉及到protobuf吗? 单tools里面的文档我在ubuntu20.04系统里也是上面的问题

holmes1412 commented 1 year ago

不涉及protobuf~

holmes1412 commented 1 year ago

需要等我晚点找个环境复现一下。 你可以先把tools/srpc_basic_controller.cc的311、312行注释掉,313行的return false改成return true,然后在tools目录下重新把srpc这个小工具编译出来看看,先感受下构建的用法🙏

ChengYe9527 commented 1 year ago

好的

ChengYe9527 commented 1 year ago

我看的只有master是有tools的,其他版本都没有

holmes1412 commented 1 year ago

是的,只有master分支有tools目录

Barenboim commented 1 year ago

我在ubuntu 22.04上,无法复现这个问题。我感觉是getopt有什么行为不一致,或者我们调用方法有什么不太对。

ChengYe9527 commented 1 year ago

有在macos上安装吗?openssl怎么解决?

Barenboim commented 1 year ago

mac上也测试过的。openssl我们默认已经安装,毕竟现场编译openssl还是太慢了。

ChengYe9527 commented 1 year ago

mac上也测过的。openssl我们默认已经安装,最终现场编译openssl还是太慢了。

openssl是什么版本呢?

holmes1412 commented 1 year ago

@ChengYe9527 可以直接使用brew install openssl 具体可以参考:https://github.com/sogou/workflow/issues/150 注意macOS有自带的ssl,所以如果使用openssl的话,brew安装之后要按照它的提示建立链接。

ChengYe9527 commented 1 year ago
截屏2023-03-31 16 18 24

你好,我这边mac编译srpc报错

holmes1412 commented 1 year ago

不确定是你原先没有安装protobuf还是系统找默认路径的不统一,建议你可以源码安装一下protobuf。

参考:

git clone -b 3.20.x https://github.com/protocolbuffers/protobuf.git protobuf.3.20
cd protobuf.3.20
sh autogen.sh
./configure
make -j4
make install
ChengYe9527 commented 1 year ago

我装的 3.6

ChengYe9527 commented 1 year ago

w

不确定是你最初没有安装protobuf还是系统找到默认路径的不均匀,建议你可以用源码安装一下protobuf。

参考:

git clone -b 3.20.x https://github.com/protocolbuffers/protobuf.git protobuf.3.20
cd protobuf.3.20
sh autogen.sh
./configure
make -j4
make install

我装了protobuf还是报错

holmes1412 commented 1 year ago

是源码安装了还报错吗?可以把新的报错信息发给我看一下~

ChengYe9527 commented 1 year ago

是源码安装了还报错了吗?可以把新的报错信息发给我看一下~

截屏2023-03-31 17 49 34
kedixa commented 1 year ago

@ChengYe9527 你好,你的处理器是Arm的吗,发一下 cat /proc/cpuinfo | head -n 30 的输出

编译一下下面的代码,并把输出发一下

#include <type_traits>
#include <iostream>

bool f() {
    return (char)-1 == (signed char)-1;
}
bool g() {
    return (char)-1 == (unsigned char)-1;
}

int main() {
    std::cout << f() << std::endl;
    std::cout << g() << std::endl;
    return 0;
}
Barenboim commented 1 year ago

修了:https://github.com/sogou/srpc/commit/d25cbfd72660474a29c71fb77e4f9f614e4c1e61

Barenboim commented 1 year ago

https://github.com/sogou/srpc/pull/298

ChengYe9527 commented 1 year ago

cat /proc/cpuinfo | head -n 30

cat: /proc/cpuinfo: No such file or directory

代码输出

1 0

Saving session... ...copying shared history... ...saving history...truncating history files... ...completed.

Barenboim commented 1 year ago

最新代码应该已经修复问题了!感谢。

ChengYe9527 commented 1 year ago

又在M1的mac上试过吗

是源代码安装了还报错了吗?可以把新的报错信息发给我看一下~

holmes1412 commented 1 year ago

@ChengYe9527 是的是一个getopt返回值原先我处理没有很细心的问题,已经修复了。麻烦再试一下,可以用你一开始的ubuntu20.04试试