我正在尝试编译消息包(http://msgpack.org/)示例代码,并不断收到这些错误,而这些错误我无法深入了解:
g++ -o"MsgPack2" ./src/MsgPack2.o -lmsgpack -lmsgpackc


这是代码:

#include <msgpack/rpc/server.h>

class myserver : public msgpack::rpc::server::base {
public:
    void add(msgpack::rpc::request req, int a1, int a2)
    {
            req.result(a1 + a2);
    }

public:
    void dispatch(msgpack::rpc::request req)
    try {
            std::string method;
            req.method().convert(&method);

            if(method == "add") {
                    msgpack::type::tuple<int, int> params;
                    req.params().convert(&params);
                    add(req, params.get<0>(), params.get<1>());

            } else {
                    req.error(msgpack::rpc::NO_METHOD_ERROR);
            }

    } catch (msgpack::type_error& e) {
            req.error(msgpack::rpc::ARGUMENT_ERROR);
            return;

    } catch (std::exception& e) {
            req.error(std::string(e.what()));
            return;
    }
};

int main(void)
{
    myserver svr;
    svr.instance.listen("127.0.0.1", 80800);
    svr.instance.run(4);  // run 4 threads

    return 0;
}

如果有人有任何想法,将不胜感激。

提前谢谢了,

最佳答案

您需要-lmsgpack-rpc

[旁注:80800不是有效的端口。]

关于C++ MsgPack : linker errors,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7024773/

10-11 14:38