1 fdbus编译运行

系统

Ubuntu 18.04.5 LTS 64bit

编译

#下载编译fdbus

cd ~/workspace

git clone git@github.com:jfq3301/fdbus.git

#我想在代码中做些修改,所以克隆的自己仓库。原始仓库是:git clone https://github.com/jeremyczhen/fdbus.git #get fdbus source code

cd fdbus

mkdir -p build/install

cd build #create directory for out-of-source build

cmake -DCMAKE_INSTALL_PREFIX=install ../cmake

make install

编译成功结果如下:

Scanning dependencies of target fdbus-clib

[ 95%] Building CXX object CMakeFiles/fdbus-clib.dir/home/jfq/1_work/12_git/fdbus/c/fdbus_clib.cpp.o

[ 97%] Building CXX object CMakeFiles/fdbus-clib.dir/home/jfq/1_work/12_git/fdbus/c/fdbus_client.cpp.o

[ 98%] Building CXX object CMakeFiles/fdbus-clib.dir/home/jfq/1_work/12_git/fdbus/c/fdbus_server.cpp.o

[100%] Linking CXX shared library libfdbus-clib.so

[100%] Built target fdbus-clib

 

#打开printf log输出

在fdbus/cmake/CMakeLists.txt修改如下选项为ON:

option(fdbus_LOG_TO_STDOUT "Log to stdout" ON)

在fdbus/server/main_ns.cpp增加头文件#include <utils/Log.h>,

在main函数中增加:LOG_D("[%s][%d]Enter.\n", __FUNCTION__, __LINE__);

再次make,结果如下:

~/1_work/12_git/fdbus/build$ ./name_server

[main][100]Enter.

 

编译protobuffer

sudo apt-get install autoconf automake libtool curl make g++ unzip

git clone https://github.com/protocolbuffers/protobuf.git

cd protobuf

git submodule update --init --recursive

./autogen.sh

./configure

make

make check

sudo make install

sudo ldconfig # refresh shared library cache.

 

make check结果如下

============================================================================

Testsuite summary for Protocol Buffers 3.9.0-rc-1

============================================================================

# TOTAL: 7

# PASS:  7

# SKIP:  0

# XFAIL: 0

# FAIL:  0

# XPASS: 0

# ERROR: 0

============================================================================

 

#编译example

##编译proto文件

protoc proto文件路径 --cpp_out=C++代码文件导出目录

cd ./fdbus/example/idl

protoc ./common.base.Example.proto --cpp_out=./idl-gen

##修改Makefile

在./fdbus/cmake/CMakeLists.txt中添加include(example.cmake),修改./fdbus/cmake/example.cmake,主要是变更路径:

link_directories(${PACKAGE_SOURCE_ROOT}/../protobuf/src/.libs)

add_executable(fdbclienttest

    ${PACKAGE_SOURCE_ROOT}/example/client-server/fdb_test_client.cpp

   ${PACKAGE_SOURCE_ROOT}/example/idl-gen/common.base.Example.pb.cc

)

target_link_libraries(fdbclienttest protobuf-lite protobuf)

编译时出现如下错误,需要添加link_directories(${PACKAGE_SOURCE_ROOT}/../protobuf/src/.libs)用于指定最新编译的protobuf路径。

fdbus/example/client-server/fdb_test_server.cpp.o:在函数‘google::protobuf::internal::GetEmptyStringAlreadyInited[abi:cxx11]()’中:

fdb_test_server.cpp:(.text._ZN6google8protobuf8internal27GetEmptyStringAlreadyInitedB5cxx11Ev[_ZN6google8protobuf8internal27GetEmptyStringAlreadyInitedB5cxx11Ev]+0x7):对‘google::protobuf::internal::fixed_address_empty_string[abi:cxx11]’未定义的引用

 

  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值