IronsDu/Joynet

不能编译Joynet动态库

Closed this issue · 15 comments

readme.md中的内容
构建步骤中
然后使用cmake进行构建Joynet动态库
报错。
环境如下:
ubuntu 16 lts
cmake version 3.5.1
GNU Make 4.2
git version 2.7.4

指令:
cd ~/Joynet
git submodule init
git submodule update
cmake .
sudo make

error如下

[ 5%] Building CXX object CMakeFiles/Joynet.dir/3rdparty/brynet/src/net/DataSocket.cpp.o
In file included from /home/edidada/Joynet/3rdparty/brynet/src/net/DataSocket.cpp:8:0:
/home/edidada/Joynet/3rdparty/brynet/src/net/DataSocket.h:4:15: fatal error: any: 没有那个文件或目录
compilation terminated.
make[2]: *** [CMakeFiles/Joynet.dir/build.make:111:CMakeFiles/Joynet.dir/3rdparty/brynet/src/net/DataSocket.cpp.o] 错误 1
make[1]: *** [CMakeFiles/Makefile2:68:CMakeFiles/Joynet.dir/all] 错误 2
make: *** [Makefile:84:all] 错误 2

不好意思,忘记修改说明了。现在 Joynet 的底层库 brynet https://github.com/IronsDu/brynet 需要使用C++17. (仅仅)因为我用了std::any。 如果你的环境只能用C++11的话,还得你自己fork去掉std::any 的使用。 (或者我空了帮你修改下)

你好怎么去掉std::any的使用,能说明一下吗,谢谢

setUD(std::any value) void DataSocket::setUD(int64_t value) 这样就可以吗

@edidada @black0592 嗯哈。
下面三个地方需要更换 int64_t (当然,如果不适用HTTP 的话,只需要修改前面两个)
https://github.com/IronsDu/brynet/blob/d0735493f1b81658a1648e4b4e2a102c37b4b752/src/brynet/net/WrapTCPService.h#L28
https://github.com/IronsDu/brynet/blob/d0735493f1b81658a1648e4b4e2a102c37b4b752/src/brynet/net/DataSocket.h#L68
https://github.com/IronsDu/brynet/blob/d0735493f1b81658a1648e4b4e2a102c37b4b752/src/brynet/net/http/HttpService.h#L42

由于我手上没有VS2013,且如果要兼容不同的编译器,以后会变得更复杂,所以还请尝试自行修改。

#include <shared_mutex> 这个也是c++17的吧

好像要改不少

你回复好快啊,^-^

@black0592 其实改好也还是快,主要是我没VS2013,我不太方便验证正确性。 嗯,包括可能代码上也有其他地方隐晦的需要C++17. 所以麻烦你改下吧。

我是在centos6.5 上编译 gcc4.8
In file included from /data/project/game_engine/Joynet/3rdparty/brynet/src/net/TCPService.cpp:7:0:
/data/project/game_engine/Joynet/3rdparty/brynet/src/net/TCPService.h:10:24: fatal error: shared_mutex: No such file or directory

在请教一下这个brynet的封包解包是怎么做的,看不太懂,能否加个qq或者微信

@black0592 加 QQ群:39284582。
总的说来,Brynet和Joynet都只提供 读取到的二进制流 [const char* buffer, size len] 给使用者,需要使用者解析buffer。 对于发送的话,则由用户自己封包,然后将封包对应的 [const char* buffer, size len] 传递给网络层(Brynet和Joynet)即可。

可以看这里的解包:
https://github.com/IronsDu/brynet/blob/master/examples/BroadCastServer.cpp#L99
再比如这里解析 cellnet 库对应的封包结构
https://github.com/IronsDu/DServerFramework/blob/master/DDServerFramework/src/WSConnectionServer/UseCellnetSingleNetSession.cpp#L16

可以看看这里的封包 (构造cellnet对应的封包结构,然后发送给后端服务):
https://github.com/IronsDu/DServerFramework/blob/master/DDServerFramework/src/WSConnectionServer/LogicServerSession.cpp#L78

cellnet 是另外一个朋友用go写的网络库,他的封包文档在:https://github.com/davyxu/cellnet#faq

@edidada @black0592 I already Compatible C++ 11.
Please checkout IronsDu/brynet@19a24ee, Help me verify it.

Ok, thanks. I'll try again when I get home