A full-fledged ONS C/C++ SDK out of its Java Counterpart taking advantage of GraalVM technology.
You can quick start demos by release binary, and also you can build it step by step as below.
Take /root/tools
as the install path, you can install the build tools by below steps.
Graalvm: Download 19.0.0ce according your OS platform to the install path and unpack it. then modify the .bash_profile
to let it enabled. then install native-image by gu install native-image
command.
# .bash_profile if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs export MAVEN_HOME=/root/tools/apache-maven export JAVA_HOME=/root/tools/graalvm-ce-19.0.0 export CMAKE_HOME=/root/tools/cmake export GRAALVM_HOME=/root/tools/graalvm-ce-19.0.0 PATH=$JAVA_HOME/bin:CMAKE_HOME/bin:$GRAALVM_HOME/bin:$MAVEN_HOME/bin:$PATH:$HOME/.local/bin:$HOME/bin export PATH
Apache Maven: Download the binary 3.6.1 to the install path and unpack it, enable it by set runtime path to .bash_profile
.
cmake: Download the binary 3.14 to the install path and unpack it, enable it by set runtime path to .bash_profile
.
g++: for centos7, the default gcc version is 4.8, you can install it by yum
yum install gcc gcc-c++
for centos6, you need update the yum repo first.
curl -Lks http://www.hop5.in/yum/el6/hop5.repo > /etc/yum.repos.d/hop5.repo yum install gcc gcc-g++
[root@7a9d198e9877 ~]# native-image --version GraalVM Version 19.0.0 CE
[root@7a9d198e9877 ~]# mvn -v Apache Maven 3.6.1 (d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555; 2019-04-04T19:00:29Z) Maven home: /root/tools/apache-maven Java version: 1.8.0_212, vendor: Oracle Corporation, runtime: /root/tools/graalvm-ee-19.0.0/jre Default locale: en_US, platform encoding: ANSI_X3.4-1968 OS name: "linux", version: "4.9.93-linuxkit-aufs", arch: "amd64", family: "unix"
[root@7a9d198e9877 ~]# cmake --version cmake version 3.14.5
[root@7a9d198e9877 ~]# g++ --version g++ (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36) Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
mvn install
root@974285cc0d03:~/OpenSource/rocketmq-ons-cpp/build# ll librocketmq_client_core.so -rwxr-xr-x 1 root root 30198632 Jul 19 07:43 librocketmq_client_core.so* root@974285cc0d03:~/OpenSource/rocketmq-ons-cpp/graalvm_artifacts# ll total 28 drwxr-xr-x 2 root root 4096 Jul 19 07:03 ./ drwxr-xr-x 14 root root 4096 Jul 25 06:05 ../ -rw-r--r-- 1 root root 4070 Jul 19 07:43 graal_isolate.h -rw-r--r-- 1 root root 4182 Jul 19 07:43 graal_isolate_dynamic.h -rw-r--r-- 1 root root 1278 Jul 19 07:43 rocketmq-ons-cpp-full.h -rw-r--r-- 1 root root 1526 Jul 19 07:43 rocketmq-ons-cpp-full_dynamic.h
mkdir dist & cd dist cmake ../ make
After building, the unit test case are installed in the dist/tests folder, you can the test case by:
make test
After building, you can package the library to a package and release it. the package contains the Head file,the lirary and the demos file. Change to the project root path,then run the package script:
sh package.sh