微服务:ICE 入门之 编译环境搭建

Love The Way You Lie 2022-07-21 00:07 233阅读 0赞

俗话说分享是学习的重要途径之一,提高自己的过程,学习,研究,应用,解决问题,总结,分享;闲来无事时便可总结下自己学习过的知识,把之前遇到过的问题也上升到方法论,把自己踩过的坑也罗列出来以防重蹈覆辙!好了,废话少说,书归正转!

本系列讲座全部是以C++部分为题讲解ICE的各个部分,从入门到精通吧;说的有点高大上了,说白了就是对我自己知识点的一个梳理吧,里面有什么错误和误导的地方也请大方的指出~~;工欲善其事必先利其器,我们的后台服务全部使用linux作为开发环境,对,ubuntu or debian都可以,哦,对了,最好64位。那接下来我们开始一阳指和六脉神剑的修炼之旅。使用的是ubuntu server 64位,其实那个版本无所谓,版本新了,系统中g++编译器支持版本高些;

  1. berli@ubuntu64:~/Test$ cat /etc/issue
  2. Ubuntu 15.10 \n \l

更新ubuntu的最新安装信息

  1. berli@ubuntu64:~$ sudo apt-get update

安装git以便我们获取最新的源代码,一个类似svn的东东,但git是比较先进和代表未来发展方向的,建议学习下

  1. <span style="font-size:18px;">berli@ubuntu64:~$ sudo apt-get install git</span>

下载ICE最新的代码

https://github.com/zeroc-ice/ice

  1. berli@ubuntu64:~/Test$ git clone --recursive https://github.com/zeroc-ice/ice.git

Center

安装编译所需要的各种依赖包,否则直接编译时会报下面的错误

  1. sudo apt-get install libssl-dev liblmdb-dev libbluetooth-dev libdbus-1-dev libbz2-dev
  2. make: pkg-config: Command not found
  3. make: pkg-config: Command not found
  4. Compiling [amd64-static] src/Slice/Grammar.cpp
  5. Compiling [amd64-static] src/Slice/Scanner.cpp
  6. Compiling [amd64-static] src/Slice/CPlusPlusUtil.cpp
  7. Compiling [amd64-static] src/Slice/JavaUtil.cpp
  8. Compiling [amd64-static] src/Slice/Parser.cpp
  9. Compiling [amd64-static] src/Slice/PythonUtil.cpp
  10. Compiling [amd64-static] src/Slice/PHPUtil.cpp
  11. 。。。。。
  12. /usr/bin/ld: cannot find -lmcpp
  13. /usr/bin/ld: cannot find -lcrypto
  14. collect2: error: ld returned 1 exit status
  15. In file included from src/IceBT/Engine.h:14:0,
  16. from src/IceBT/Engine.cpp:10:
  17. src/IceBT/Config.h:16:33: fatal error: bluetooth/bluetooth.h: No such file or directory
  18. src/IceBT/DBus.cpp:15:23: fatal error: dbus/dbus.h: No such file or directory
  19. compilation terminated.

Berkeley DB下载,编译,安装

下载:

Skip to end of metadata

Go to start of metadata

  1. $ wget https://zeroc.com/download/berkeley-db/db-5.3.28.NC.tar.gz

解压:

  1. $ tar xzf db-5.3.28.NC.tar.gz

必须给bdb打patch,否则编译后无法使用

  1. $ cd db-5.3.28.NC/build_unix
  2. $ patch -p0 < ../db/patch.db.5.3.28 $ ../dist/configure --enable-cxx --enable-java

编译&安装

$ make

  1. $ sudo make install

On a 64-bit platform, you need to create a lib64 symbolic link to the lib directory:

  1. $ cd /opt/db53
  2. $ ln -s lib lib64
  3. 安装mcpp,从zeroic的给的github下载源码
  4. Clone the zeroc-inc/mcpp repository hosted on GitHub:
  5. $ git clone https://github.com/zeroc-ice/mcpp.git

进入目录,make,sudo make install就可以了

也可以直接下载mcpp,按照下面步骤执行命令,编译,安装

  1. http://prdownloads.sourceforge.net/mcpp/mcpp-2.7.2.tar.gz?download
  2. tar xvf mcpp-2.7.2.tar.gz
  3. cd mcpp-2.7.2
  4. patch -p0 < ../mcpp/patch.mcpp.2.7.2
  5. ./configure CFLAGS=-fPIC --enable-mcpplib --disable-shared
  6. make && make install

OK,安装上面依赖的各种开源库,我们现在请我们的主角ICE登场,万事俱备只欠东风~,进入cd ice/cpp目录,开始make,

经过漫长的编译时间后,执行sudo make install完成了安装;到此,我们完成了ice编译环境的搭建。

Center 1

ICE默认是安装到/opt目录,我们要拷贝到/usr/local/bin(当然你也可以/usr/bin)

把ICE的bin文件拷贝到/usr/local/bin

  1. sudo cp /opt/Ice-3.7a3/bin/ /usr/local/bin/

测试下slice2cpp

Center 2

发表评论

表情:
评论列表 (有 0 条评论,233人围观)

还没有评论,来说两句吧...

相关阅读