博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ProtoBuf使用指南(C++)
阅读量:5991 次
发布时间:2019-06-20

本文共 1314 字,大约阅读时间需要 4 分钟。

ProtoBuf使用指南(C++)

Created: Mar 12, 2019 6:47 PM

Last Edited Time: Mar 22, 2019 1:51 PM

1.安装部署

  1. 去官网(gitHub下载,现在用的版本是protobuf-all-3.7.0.zip)

  2. 去Cmake官网下载Cmake(cmake-3.14.0-rc4-win64-x64)

  3. 操作Cmake对Proto的源码进行处理

    untitled?AWSAccessKeyId=ASIAT73L2G45LO2UU7S3&Expires=1555470203&Signature=XCcPj4pR6O66OERb5WCCgGvZanI%3D&x-amz-security-token=AgoJb3JpZ2luX2VjEDEaCXVzLXdlc3QtMiJHMEUCIQCoZ6Yn2HM602UPv1OWhRkyJC0RZO808vL20tulugzQ0wIgQyUe72QucUZM1uZMnduTUkVSnhWh3g0Pl5Dx2dnd3B0q4wMI%2Bv%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FARAAGgwyNzQ1NjcxNDkzNzAiDOFfeCgqzgOWttXrciq3A7Hg4BtA3AhVnr4Qy2vkFN7VLHwl%2FT7zUyel2bOoaQjHx%2FnGx7BexEDLxq9KfIG7HekJH%2Bu%2Bb8CTulr1kOXpyawTqmEELn7P6azYx3koyHlQihv7tjOmH4nevxFQYwiLXLI%2FA050HFX0QVOLlAT6Vfh8ehJ48BG0gIsvOee5CeInTmGvYc4JY9i4rnS%2BwO6xMpOmy9uzSZBvITjnotuY49LckiWPRM1IIn0EX1Luld%2FXiGnEJ9jWJ%2BSeFcOvnXQDAjLwY8yj0DsILFEVvWwVfrtTxcnhMSK0EVIN9zt42Sva8tucF7ktXTFehduY5v6wDHBs5RRQjD7wo06EzTTmOJJMXAapILKgPJmmmNRRlSZ3JHXj3JyTi3fNhbiGxvX%2FrLvwSGi%2FtKjk6XzQLaPxXpJB33MoXQgfORNQhK2%2FxnBLpZIcKozZmrp5%2BJQvZcT4BWkcHdfc9ZLhN9zXGPgnGmhaVqVoMgYHJUoYpU6qLnTBnfrKDh4N6%2BojdfufDOhcpsaSk8sueMPUjI8wyQBwdm3NERKjewmH5bsakel1xcc07C5P%2BZtn3jb5BtCBaPJ%2FdIZZobfIfB0wi8rU5QU6tAGxhlUfQeGqGyLfgp6sgbsztx0qHDwyHxl1dEawmRLOL%2F2rTWPAA%2BKx8ahmcdz0zu6X6AydAblTqe%2FOlwiRkoe7mdQOdRD054jncqarkiqViZ%2FGogiG1MszEuQerIZFzNPB3rITRME362oHvD6bNTGJTHueKeDbth4C5c7d9PBVCB5LHhg6F5nTgXNPE%2BdsxSqO%2BEanIBjFDEEqVDZmJVJarTr4d9hn14QySIfQhGskdLQvtl0%3D

  4. Cmake第二步

    untitled?AWSAccessKeyId=ASIAT73L2G45LO2UU7S3&Expires=1555470203&Signature=0mfsT8vNy3sQbW%2BMh6wyQKG1NUg%3D&x-amz-security-token=AgoJb3JpZ2luX2VjEDEaCXVzLXdlc3QtMiJHMEUCIQCoZ6Yn2HM602UPv1OWhRkyJC0RZO808vL20tulugzQ0wIgQyUe72QucUZM1uZMnduTUkVSnhWh3g0Pl5Dx2dnd3B0q4wMI%2Bv%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FARAAGgwyNzQ1NjcxNDkzNzAiDOFfeCgqzgOWttXrciq3A7Hg4BtA3AhVnr4Qy2vkFN7VLHwl%2FT7zUyel2bOoaQjHx%2FnGx7BexEDLxq9KfIG7HekJH%2Bu%2Bb8CTulr1kOXpyawTqmEELn7P6azYx3koyHlQihv7tjOmH4nevxFQYwiLXLI%2FA050HFX0QVOLlAT6Vfh8ehJ48BG0gIsvOee5CeInTmGvYc4JY9i4rnS%2BwO6xMpOmy9uzSZBvITjnotuY49LckiWPRM1IIn0EX1Luld%2FXiGnEJ9jWJ%2BSeFcOvnXQDAjLwY8yj0DsILFEVvWwVfrtTxcnhMSK0EVIN9zt42Sva8tucF7ktXTFehduY5v6wDHBs5RRQjD7wo06EzTTmOJJMXAapILKgPJmmmNRRlSZ3JHXj3JyTi3fNhbiGxvX%2FrLvwSGi%2FtKjk6XzQLaPxXpJB33MoXQgfORNQhK2%2FxnBLpZIcKozZmrp5%2BJQvZcT4BWkcHdfc9ZLhN9zXGPgnGmhaVqVoMgYHJUoYpU6qLnTBnfrKDh4N6%2BojdfufDOhcpsaSk8sueMPUjI8wyQBwdm3NERKjewmH5bsakel1xcc07C5P%2BZtn3jb5BtCBaPJ%2FdIZZobfIfB0wi8rU5QU6tAGxhlUfQeGqGyLfgp6sgbsztx0qHDwyHxl1dEawmRLOL%2F2rTWPAA%2BKx8ahmcdz0zu6X6AydAblTqe%2FOlwiRkoe7mdQOdRD054jncqarkiqViZ%2FGogiG1MszEuQerIZFzNPB3rITRME362oHvD6bNTGJTHueKeDbth4C5c7d9PBVCB5LHhg6F5nTgXNPE%2BdsxSqO%2BEanIBjFDEEqVDZmJVJarTr4d9hn14QySIfQhGskdLQvtl0%3D

  5. Cmake第三步:Configure成功后,返回Cmake首页选择确定要编译的相关组件(不知道具体每个组件的作用,图上打勾的必选,其余可选,不确定就全选)

    untitled?AWSAccessKeyId=ASIAT73L2G45LO2UU7S3&Expires=1555470203&Signature=RlU062LE6OZzhT8ituDx9nfe%2ByE%3D&x-amz-security-token=AgoJb3JpZ2luX2VjEDEaCXVzLXdlc3QtMiJHMEUCIQCoZ6Yn2HM602UPv1OWhRkyJC0RZO808vL20tulugzQ0wIgQyUe72QucUZM1uZMnduTUkVSnhWh3g0Pl5Dx2dnd3B0q4wMI%2Bv%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FARAAGgwyNzQ1NjcxNDkzNzAiDOFfeCgqzgOWttXrciq3A7Hg4BtA3AhVnr4Qy2vkFN7VLHwl%2FT7zUyel2bOoaQjHx%2FnGx7BexEDLxq9KfIG7HekJH%2Bu%2Bb8CTulr1kOXpyawTqmEELn7P6azYx3koyHlQihv7tjOmH4nevxFQYwiLXLI%2FA050HFX0QVOLlAT6Vfh8ehJ48BG0gIsvOee5CeInTmGvYc4JY9i4rnS%2BwO6xMpOmy9uzSZBvITjnotuY49LckiWPRM1IIn0EX1Luld%2FXiGnEJ9jWJ%2BSeFcOvnXQDAjLwY8yj0DsILFEVvWwVfrtTxcnhMSK0EVIN9zt42Sva8tucF7ktXTFehduY5v6wDHBs5RRQjD7wo06EzTTmOJJMXAapILKgPJmmmNRRlSZ3JHXj3JyTi3fNhbiGxvX%2FrLvwSGi%2FtKjk6XzQLaPxXpJB33MoXQgfORNQhK2%2FxnBLpZIcKozZmrp5%2BJQvZcT4BWkcHdfc9ZLhN9zXGPgnGmhaVqVoMgYHJUoYpU6qLnTBnfrKDh4N6%2BojdfufDOhcpsaSk8sueMPUjI8wyQBwdm3NERKjewmH5bsakel1xcc07C5P%2BZtn3jb5BtCBaPJ%2FdIZZobfIfB0wi8rU5QU6tAGxhlUfQeGqGyLfgp6sgbsztx0qHDwyHxl1dEawmRLOL%2F2rTWPAA%2BKx8ahmcdz0zu6X6AydAblTqe%2FOlwiRkoe7mdQOdRD054jncqarkiqViZ%2FGogiG1MszEuQerIZFzNPB3rITRME362oHvD6bNTGJTHueKeDbth4C5c7d9PBVCB5LHhg6F5nTgXNPE%2BdsxSqO%2BEanIBjFDEEqVDZmJVJarTr4d9hn14QySIfQhGskdLQvtl0%3D

  6. Cmake最后一步,点击Generate,生成成功则编译成功。(注:如果ProtoBuf是64位的或者想要在x64平台上编译,一定要选择x64,默认为32,不选会出错。)随后,在输出目录就会有编译完成的文件。

  7. 打开Cmake处理完成的文件,目录下有个.sln文件,用vs2017打开,对项目进行编译(也可以只编译libprotobufd/libprotocd/libprotobuf-lited等几个项目,我这里直接全部编译-F6),编译前注意是Debug方式,平台为X64。没有报错基本就是编译成功了。

  8. 打开编译OK的文件,进入Debug目录,目录下大致文件如下,这样基本就是成功了。(网上有人编译后的lib和protoc.exe不一样大,除了版本问题外还有可能编译过程有问题,自己把握)

    untitled?AWSAccessKeyId=ASIAT73L2G45LO2UU7S3&Expires=1555470203&Signature=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NPE%2BdsxSqO%2BEanIBjFDEEqVDZmJVJarTr4d9hn14QySIfQhGskdLQvtl0%3D

    2:C++程序使用指南

    1. 写一个.proto文件,命名为msg.proto

      untitled?AWSAccessKeyId=ASIAT73L2G45LO2UU7S3&Expires=1555470203&Signature=%2B%2BPdCC8bzC8q3XLixgargwQyGwM%3D&x-amz-security-token=AgoJb3JpZ2luX2VjEDEaCXVzLXdlc3QtMiJHMEUCIQCoZ6Yn2HM602UPv1OWhRkyJC0RZO808vL20tulugzQ0wIgQyUe72QucUZM1uZMnduTUkVSnhWh3g0Pl5Dx2dnd3B0q4wMI%2Bv%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FARAAGgwyNzQ1NjcxNDkzNzAiDOFfeCgqzgOWttXrciq3A7Hg4BtA3AhVnr4Qy2vkFN7VLHwl%2FT7zUyel2bOoaQjHx%2FnGx7BexEDLxq9KfIG7HekJH%2Bu%2Bb8CTulr1kOXpyawTqmEELn7P6azYx3koyHlQihv7tjOmH4nevxFQYwiLXLI%2FA050HFX0QVOLlAT6Vfh8ehJ48BG0gIsvOee5CeInTmGvYc4JY9i4rnS%2BwO6xMpOmy9uzSZBvITjnotuY49LckiWPRM1IIn0EX1Luld%2FXiGnEJ9jWJ%2BSeFcOvnXQDAjLwY8yj0DsILFEVvWwVfrtTxcnhMSK0EVIN9zt42Sva8tucF7ktXTFehduY5v6wDHBs5RRQjD7wo06EzTTmOJJMXAapILKgPJmmmNRRlSZ3JHXj3JyTi3fNhbiGxvX%2FrLvwSGi%2FtKjk6XzQLaPxXpJB33MoXQgfORNQhK2%2FxnBLpZIcKozZmrp5%2BJQvZcT4BWkcHdfc9ZLhN9zXGPgnGmhaVqVoMgYHJUoYpU6qLnTBnfrKDh4N6%2BojdfufDOhcpsaSk8sueMPUjI8wyQBwdm3NERKjewmH5bsakel1xcc07C5P%2BZtn3jb5BtCBaPJ%2FdIZZobfIfB0wi8rU5QU6tAGxhlUfQeGqGyLfgp6sgbsztx0qHDwyHxl1dEawmRLOL%2F2rTWPAA%2BKx8ahmcdz0zu6X6AydAblTqe%2FOlwiRkoe7mdQOdRD054jncqarkiqViZ%2FGogiG1MszEuQerIZFzNPB3rITRME362oHvD6bNTGJTHueKeDbth4C5c7d9PBVCB5LHhg6F5nTgXNPE%2BdsxSqO%2BEanIBjFDEEqVDZmJVJarTr4d9hn14QySIfQhGskdLQvtl0%3D

    2. 新建一个C++空的项目,从build的protoBug文件的Debug目录下拷贝下面的文件到项目名目录下(如项目叫“Project”,目标目录是“Project/Project”),并且把msg.proto文件也拷贝到这个目录下

      untitled?AWSAccessKeyId=ASIAT73L2G45LO2UU7S3&Expires=1555470203&Signature=%2B%2BPdCC8bzC8q3XLixgargwQyGwM%3D&x-amz-security-token=AgoJb3JpZ2luX2VjEDEaCXVzLXdlc3QtMiJHMEUCIQCoZ6Yn2HM602UPv1OWhRkyJC0RZO808vL20tulugzQ0wIgQyUe72QucUZM1uZMnduTUkVSnhWh3g0Pl5Dx2dnd3B0q4wMI%2Bv%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FARAAGgwyNzQ1NjcxNDkzNzAiDOFfeCgqzgOWttXrciq3A7Hg4BtA3AhVnr4Qy2vkFN7VLHwl%2FT7zUyel2bOoaQjHx%2FnGx7BexEDLxq9KfIG7HekJH%2Bu%2Bb8CTulr1kOXpyawTqmEELn7P6azYx3koyHlQihv7tjOmH4nevxFQYwiLXLI%2FA050HFX0QVOLlAT6Vfh8ehJ48BG0gIsvOee5CeInTmGvYc4JY9i4rnS%2BwO6xMpOmy9uzSZBvITjnotuY49LckiWPRM1IIn0EX1Luld%2FXiGnEJ9jWJ%2BSeFcOvnXQDAjLwY8yj0DsILFEVvWwVfrtTxcnhMSK0EVIN9zt42Sva8tucF7ktXTFehduY5v6wDHBs5RRQjD7wo06EzTTmOJJMXAapILKgPJmmmNRRlSZ3JHXj3JyTi3fNhbiGxvX%2FrLvwSGi%2FtKjk6XzQLaPxXpJB33MoXQgfORNQhK2%2FxnBLpZIc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jD7wo06EzTTmOJJMXAapILKgPJmmmNRRlSZ3JHXj3JyTi3fNhbiGxvX%2FrLvwSGi%2FtKjk6XzQLaPxXpJB33MoXQgfORNQhK2%2FxnBLpZIcKozZmrp5%2BJQvZcT4BWkcHdfc9ZLhN9zXGPgnGmhaVqVoMgYHJUoYpU6qLnTBnfrKDh4N6%2BojdfufDOhcpsaSk8sueMPUjI8wyQBwdm3NERKjewmH5bsakel1xcc07C5P%2BZtn3jb5BtCBaPJ%2FdIZZobfIfB0wi8rU5QU6tAGxhlUfQeGqGyLfgp6sgbsztx0qHDwyHxl1dEawmRLOL%2F2rTWPAA%2BKx8ahmcdz0zu6X6AydAblTqe%2FOlwiRkoe7mdQOdRD054jncqarkiqViZ%2FGogiG1MszEuQerIZFzNPB3rITRME362oHvD6bNTGJTHueKeDbth4C5c7d9PBVCB5LHhg6F5nTgXNPE%2BdsxSqO%2BEanIBjFDEEqVDZmJVJarTr4d9hn14QySIfQhGskdLQvtl0%3D

    3. 打开CMD,跳到msg.proto所在的文件目录下,执行下面的这个命令(addressbook.proto→msg.proto)

      untitled?AWSAccessKeyId=ASIAT73L2G45LO2UU7S3&Expires=1555470203&Signature=8snrXJnoLq5mFzX9J%2F1%2B3v9s1t8%3D&x-amz-security-token=AgoJb3JpZ2luX2VjEDEaCXVzLXdlc3QtMiJHMEUCIQCoZ6Yn2HM602UPv1OWhRkyJC0RZO808vL20tulugzQ0wIgQyUe72QucUZM1uZMnduTUkVSnhWh3g0Pl5Dx2dnd3B0q4wMI%2Bv%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FARAAGgwyNzQ1NjcxNDkzNzAiDOFfeCgqzgOWttXrciq3A7Hg4BtA3AhVnr4Qy2vkFN7VLHwl%2FT7zUyel2bOoaQjHx%2FnGx7BexEDLxq9KfIG7HekJH%2Bu%2Bb8CTulr1kOXpyawTqmEELn7P6azYx3koyHlQihv7tjOmH4nevxFQYwiLXLI%2FA050HFX0QVOLlAT6Vfh8ehJ48BG0gIsvOee5CeInTmGvYc4JY9i4rnS%2BwO6xMpOmy9uzSZBvITjnotuY49LckiWPRM1IIn0EX1Luld%2FXiGnEJ9jWJ%2BSeFcOvnXQDAjLwY8yj0DsILFEVvWwVfrtTxcnhMSK0EVIN9zt42Sva8tucF7ktXTFehduY5v6wDHBs5RRQjD7wo06EzTTmOJJMXAapILKgPJmmmNRRlSZ3JHXj3JyTi3fNhbiGxvX%2FrLvwSGi%2FtKjk6XzQLaPxXpJB33MoXQgfORNQhK2%2FxnBLpZIcKozZmrp5%2BJQvZcT4BWkcHdfc9ZLhN9zXGPgnGmhaVqVoMgYHJUoYpU6qLnTBnfrKDh4N6%2BojdfufDOhcpsaSk8sueMPUjI8wyQBwdm3NERKjewmH5bsakel1xcc07C5P%2BZtn3jb5BtCBaPJ%2FdIZZobfIfB0wi8rU5QU6tAGxhlUfQeGqGyLfgp6sgbsztx0qHDwyHxl1dEawmRLOL%2F2rTWPAA%2BKx8ahmcdz0zu6X6AydAblTqe%2FOlwiRkoe7mdQOdRD054jncqarkiqViZ%2FGogiG1MszEuQerIZFzNPB3rITRME362oHvD6bNTGJTHueKeDbth4C5c7d9PBVCB5LHhg6F5nTgXNPE%2BdsxSqO%2BEanIBjFDEEqVDZmJVJarTr4d9hn14QySIfQhGskdLQvtl0%3D

    4. 执行完成之后生成两个文件:msg.pb.h和msg.pb.cc,打开这两个文件,搜索下msg里面的字段,如果有has_clientid() 这类字样说明生成成功了。(鉴于我第一次就生成失败了,这一步检查还是很有必要的)

    5. 用VS打开刚刚的项目,右击添加项目:msg.pb.h和msg.pb.cc。

    6. 配置环境:

      1. 右击项目→属性→vc++目录→包含目录 添加protoBuf的src目录

        untitled?AWSAccessKeyId=ASIAT73L2G45PUI2JDF6&Expires=1555470203&Signature=mX5IJD7mmn51D%2BACH%2B8KcklplWY%3D&x-amz-security-token=AgoJb3JpZ2luX2VjEDAaCXVzLXdlc3QtMiJIMEYCIQDs5nh%2BRLKeQF110pE05d70XgjmclOp5YrsOf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属性→C/C++→预处理器定义添加_CRT_SECURE_NO_DEPRECATE和PROTOBUF_USE_DLLS

        untitled?AWSAccessKeyId=ASIAT73L2G45PUI2JDF6&Expires=1555470203&Signature=u%2BEalTXzdhaoMHv9aYmROWAxUBk%3D&x-amz-security-token=AgoJb3JpZ2luX2VjEDAaCXVzLXdlc3QtMiJIMEYCIQDs5nh%2BRLKeQF110pE05d70XgjmclOp5YrsOf8PtsnMvgIhAK7Y8dK4mkyIU0CakqnqZOlPtiYa7cTViNfhVJQblZiQKuMDCPn%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEQABoMMjc0NTY3MTQ5MzcwIgwPpUc9JYaHI%2BPMTqgqtwNK%2BewVTw%2BIs7QK0NykkaAjot6tA2f%2FC3jeq8yG4gH8Md7b7L7AYUYyPPuEGwampADNzmr%2BczNM7Nvu8Qbf41oN%2BmNphluK2V6q8Xz8gKg2%2BlRiLJzQbAOunjOWpAl6%2FoYjknG1cL40VK3W%2BQx8CX0w3OB90NIXpgSWH3EcynwjG3D%2BZ%2BgHsWb%2B11l9SG8ZuphQal3qxM0IZVZGc6uk5Dxyt%2FrBr%2BOTG5NIY6cx4SAFdqQZwRr4CezJz5kaMG4PrboJul8rXRfSUQPurJRY%2F%2Bx4qtmB%2B00UM%2F%2F9yIK2LKvTJYDLJkvXmizGqZpWIh0xLP3Ba2JfPqIsK8tlJIP3r6fivgvBUZsymXzdAF7rukO%2BvJkFn38eyYY9YCGsVtHy3WYVPmIvVQwDl7SZ7YrAVWeOHwWP9PUtQMYplvN7SbJZy%2BVf4vYmZO3YYD8RQA9qJ4f5FQRPaoht%2BXuvt5%2BWghra%2FJzfN8c%2B4PUcaSMFfc4k4jRLO%2BWG6%2B1vKGGJmTjJBk0pL4V%2F6eqp6cWWlIJS79uRArgLUkobx9WLCqVUO8L5HnfYDVRETYDsEm6SUOHAwk9KLOv6ntwrMKq81OUFOrMBcVDwMf%2BW%2BcLq5j5IYlp1pSdKrMAR7lzQ088iVjYZlFWM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ghra%2FJzfN8c%2B4PUcaSMFfc4k4jRLO%2BWG6%2B1vKGGJmTjJBk0pL4V%2F6eqp6cWWlIJS79uRArgLUkobx9WLCqVUO8L5HnfYDVRETYDsEm6SUOHAwk9KLOv6ntwrMKq81OUFOrMBcVDwMf%2BW%2BcLq5j5IYlp1pSdKrMAR7lzQ088iVjYZlFWMpTmpYdNqkKYvwlZK%2BaWRuZ0Mjlh7cFV9Gq7D3teotVo1Nj2wz0pW0W5fmb6l3fjQwRX5ToD4fPgY1qbfj1%2B5CjvpKiPlnuTaqRhHGWH3YgBkn%2FgR6r3yD%2BMU9W7N4bu7dzHrp9Mr7h8%2FP1pDNZU6bAE%2BCenWk%2F0G2QZEv81tm9MES6DsCnR4s2TVJhALxYeSk9o%3D
      4. 链接器→附加库目录 添加项目目录(前提是各种lib文件已经复制到项目目录中)

        untitled?AWSAccessKeyId=ASIAT73L2G45PUI2JDF6&Expires=1555470203&Signature=XFGkoIx2B5fOjgbBkxCbTIxjixs%3D&x-amz-security-token=AgoJb3JpZ2luX2VjEDAaCXVzLXdlc3QtMiJIMEYCIQDs5nh%2BRLKeQF110pE05d70XgjmclOp5YrsOf8PtsnMvgIhAK7Y8dK4mkyIU0CakqnqZOlPtiYa7cTViNfhVJQblZiQKuMDCPn%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEQABoMMjc0NTY3MTQ5MzcwIgwPpUc9JYaHI%2BPMTqgqtwNK%2BewVTw%2BIs7QK0NykkaAjot6tA2f%2FC3jeq8yG4gH8Md7b7L7AYUYyPPuEGwampADNzmr%2BczNM7Nvu8Qbf41oN%2BmNphluK2V6q8Xz8gKg2%2BlRiLJzQbAOunjOWpAl6%2FoYjknG1cL40VK3W%2BQx8CX0w3OB90NIXpgSWH3EcynwjG3D%2BZ%2BgHsWb%2B11l9SG8ZuphQal3qxM0IZVZGc6uk5Dxyt%2FrBr%2BOTG5NIY6cx4SAFdqQZwRr4CezJz5kaMG4PrboJul8rXRfSUQPurJRY%2F%2Bx4qtmB%2B00UM%2F%2F9yIK2LKvTJYDLJkvXmizGqZpWIh0xLP3Ba2JfPqIsK8tlJIP3r6fivgvBUZsymXzdAF7rukO%2BvJkFn38eyYY9YCGsVtHy3WYVPmIvVQwDl7SZ7YrAVWeOHwWP9PUtQMYplvN7SbJZy%2BVf4vYmZO3YYD8RQA9qJ4f5FQRPaoht%2BXuvt5%2BWghra%2FJzfN8c%2B4PUcaSMFfc4k4jRLO%2BWG6%2B1vKGGJmTjJBk0pL4V%2F6eqp6cWWlIJS79uRArgLUkobx9WLCqVUO8L5HnfYDVRETYDsEm6SUOHAwk9KLOv6ntwrMKq81OUFOrMBcVDwMf%2BW%2BcLq5j5IYlp1pSdKrMAR7lzQ088iVjYZlFWMpTmpYdNqkKYvwlZK%2BaWRuZ0Mjlh7cFV9Gq7D3teotVo1Nj2wz0pW0W5fmb6l3fjQwRX5ToD4fPgY1qbfj1%2B5CjvpKiPlnuTaqRhHGWH3YgBkn%2FgR6r3yD%2BMU9W7N4bu7dzHrp9Mr7h8%2FP1pDNZU6bAE%2BCenWk%2F0G2QZEv81tm9MES6DsCnR4s2TVJhALxYeSk9o%3D

      5. 链接器→输入→附加依赖项 添加lib文件名

        untitled?AWSAccessKeyId=ASIAT73L2G45PUI2JDF6&Expires=1555470203&Signature=U6LygoocsnGSCdKdav9NSvhkwgI%3D&x-amz-security-token=AgoJb3JpZ2luX2VjEDAaCXVzLXdlc3QtMiJIMEYCIQDs5nh%2BRLKeQF110pE05d70XgjmclOp5YrsOf8PtsnMvgIhAK7Y8dK4mkyIU0CakqnqZOlPtiYa7cTViNfhVJQblZiQKuMDCPn%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEQABoMMjc0NTY3MTQ5MzcwIgwPpUc9JYaHI%2BPMTqgqtwNK%2BewVTw%2BIs7QK0NykkaAjot6tA2f%2FC3jeq8yG4gH8Md7b7L7AYUYyPPuEGwampADNzmr%2BczNM7Nvu8Qbf41oN%2BmNphluK2V6q8Xz8gKg2%2BlRiLJzQbAOunjOWpAl6%2FoYjknG1cL40VK3W%2BQx8CX0w3OB90NIXpgSWH3EcynwjG3D%2BZ%2BgHsWb%2B11l9SG8ZuphQal3qxM0IZVZGc6uk5Dxyt%2FrBr%2BOTG5NIY6cx4SAFdqQZwRr4CezJz5kaMG4PrboJul8rXRfSUQPurJRY%2F%2Bx4qtmB%2B00UM%2F%2F9yIK2LKvTJYDLJkvXmizGqZpWIh0xLP3Ba2JfPqIsK8tlJIP3r6fivgvBUZsymXzdAF7rukO%2BvJkFn38eyYY9YCGsVtHy3WYVPmIvVQwDl7SZ7YrAVWeOHwWP9PUtQMYplvN7SbJZy%2BVf4vYmZO3YYD8RQA9qJ4f5FQRPaoht%2BXuvt5%2BWghra%2FJzfN8c%2B4PUcaSMFfc4k4jRLO%2BWG6%2B1vKGGJmTjJBk0pL4V%2F6eqp6cWWlIJS79uRArgLUkobx9WLCqVUO8L5HnfYDVRETYDsEm6SUOHAwk9KLOv6ntwrMKq81OUFOrMBcVDwMf%2BW%2BcLq5j5IYlp1pSdKrMAR7lzQ088iVjYZlFWMpTmpYdNqkKYvwlZK%2BaWRuZ0Mjlh7cFV9Gq7D3teotVo1Nj2wz0pW0W5fmb6l3fjQwRX5ToD4fPgY1qbfj1%2B5CjvpKiPlnuTaqRhHGWH3YgBkn%2FgR6r3yD%2BMU9W7N4bu7dzHrp9Mr7h8%2FP1pDNZU6bAE%2BCenWk%2F0G2QZEv81tm9MES6DsCnR4s2TVJhALxYeSk9o%3D


        环境配置完毕

    7. 新建Client.cpp,编译,启动。

    8. 将项目文件整体复制出来,修改Client.cpp为Server.cpp编译,启动。

    9. 通讯完成

      untitled?AWSAccessKeyId=ASIAT73L2G45PUI2JDF6&Expires=1555470203&Signature=kh7wSEdEf3FRE0DBi3il%2BMMkDls%3D&x-amz-security-token=AgoJb3JpZ2luX2VjEDAaCXVzLXdlc3QtMiJIMEYCIQDs5nh%2BRLKeQF110pE05d70XgjmclOp5YrsOf8PtsnMvg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s.com/NewBee-CHH/p/10715701.html

你可能感兴趣的文章
[javaSE] 集合框架(迭代器)
查看>>
测试-一个unity的编译bug,初始化器
查看>>
2016/04/13
查看>>
Servlet简介
查看>>
--@angularJS--路由、模块、依赖注入
查看>>
task可声明参数 z
查看>>
linux开机服务自启
查看>>
利用ssh反向代理以及autossh实现从外网连接内网服务器
查看>>
转:Alpha、Beta、RC、GA、PRE版本的区别
查看>>
vue项目配置使用flow类型检查
查看>>
shell中的函数 shell中的数组 告警系统需求分析
查看>>
百度地图 绘制东莞东城地图示例
查看>>
【mysql】mysql增加version字段实现乐观锁,实现高并发下的订单库存的并发控制,通过开启多线程同时处理模拟多个请求同时到达的情况 + 同一事务中使用多个乐观锁的情况处理...
查看>>
游北国风光,忆南国之乡
查看>>
python3 使用ldap3来作为django认证后台
查看>>
Asp.net core中的依赖注入
查看>>
CountDownLatch与CyclicBarrier
查看>>
git合并分支
查看>>
如何在Windows中使用不同字体显示中文/日文和英文
查看>>
mfc ui库
查看>>