fdbus和proto编译

1. 下载protobuf和FDBUS

1.下载
FDBUS需要用到protobuf,所以需要提前安装好protobuf。

protobuf下载地址

https://gitee.com/it-monkey/protocolbuffers/

fdbus下载地址

https://gitee.com/jeremyczhen/fdbus

2. Windows编译

生成vs工程

打开CMake,没有的话先下载安装一个

指定路径,设置关闭zlib

protobuf_WITH_ZLIB=OFF
CMAKE_INSTALL_PREFIX=install
Configure,Generate后生成vs工程
fdbus和proto编译_第1张图片

vs2017编译

用vs2017打开build/protobuf.sln,构建project INSTALL,得到proto库

生成vs工程

打开CMake,没有的话先下载安装一个

指定路径,添加proto安装路径

SYSTEM_ROOT=D:\chenchao\workspace\protocolbuffers-master\cmake\build\install

修改CMAKE_INSTALL_PREFIX=install

将D:\chenchao\workspace\protocolbuffers-master\cmake\build\install\bin添加为环境变量

Configure,Generate后生成vs工程

fdbus和proto编译_第2张图片

vs2017编译

参考指导文档

https://fdbus.readthedocs.io/en/latest/readme.html#how-to-build

用vs2017打开build/fdbus.sln,构建project INSTALL,得到fdbus库
fdbus和proto编译_第3张图片

3. Linux编译

protocolbuffers-master\cmake\文件夹下建build文件夹

cmake ..
make

fdbus-master\cmake\文件夹下建build文件夹
修改CMakeLists.txt
151行左右改为静态编译
set(LIB_BUILD_TYPE "STATIC")
空白处追加
set(CMAKE_CXX_FLAGS "-fPIC")

cmake ..
make

4. Android编译

参考https://blog.csdn.net/chen_227/article/details/131759730?spm=1001.2014.3001.5502 的步骤2

主要是修改build_assimp.batbuild.bat
proto的如下

@REM @echo off  
cls  
  
REM *NOTE* Change these based on   
REM SET ASSIMP_DIR=assimp-5.0.0
SET OUTPUT_DIR=build-arm 
SET ANDROID_PATH=D:/chenchao/workspace/Android/Android/Sdk
SET NDK_PATH=D:/chenchao/workspace/Android/Android/Sdk/ndk/23.1.7779620
SET NDK_TOOLCHAIN=%ANDROID_PATH%/ndk/android-toolchain-16-llvm-arm
SET CMAKE_TOOLCHAIN=%NDK_PATH%/build/cmake/android.toolchain.cmake  
SET CMAKE_PATH=%ANDROID_PATH%/cmake/3.22.1
  
REM *NOTE* Careful if you don't want rm -rf, I use it for testing purposes.  
del \F \S \Q %OUTPUT_DIR%
mkdir %OUTPUT_DIR%  
  
REM pushd doesn't seem to work ):<  
cd %OUTPUT_DIR%  
  
if not defined ORIGPATH set ORIGPATH=%PATH%  
SET PATH=%CMAKE_PATH%/bin;%ANDROID_PATH%/tools;%ANDROID_PATH%/platform-tools;%ORIGPATH%;%NDK_TOOLCHAIN%/bin;
  
%CMAKE_PATH%/bin/cmake.exe -GNinja -DCMAKE_TOOLCHAIN_FILE=%CMAKE_TOOLCHAIN%  -DANDROID_ABI="armeabi-v7a"  -DANDROID_NDK=%NDK_PATH% -DCMAKE_MAKE_PROGRAM=%CMAKE_PATH%/bin/ninja.exe -DCMAKE_BUILD_TYPE=Release  -DANDROID_NATIVE_API_LEVEL=24 -DANDROID_FORCE_ARM_BUILD=TRUE -DCMAKE_INSTALL_PREFIX=install -DANDROID_STL=c++_static -DCMAKE_CXX_FLAGS=-Wno-c++11-narrowing -DANDROID_TOOLCHAIN=clang -Dprotobuf_BUILD_TESTS=OFF ../
  
%CMAKE_PATH%/bin/cmake.exe --build .

cd ..

fdbus的CMakeLists.txt参考步骤3做静态编译修改
fdbus的如下

@REM @echo off  
cls  
  
REM *NOTE* Change these based on   
REM SET ASSIMP_DIR=assimp-5.0.0
SET OUTPUT_DIR=build-arm 
SET ANDROID_PATH=D:/chenchao/workspace/Android/Android/Sdk
SET NDK_PATH=D:/chenchao/workspace/Android/Android/Sdk/ndk/23.1.7779620
SET NDK_TOOLCHAIN=%ANDROID_PATH%/ndk/android-toolchain-16-llvm-arm
SET CMAKE_TOOLCHAIN=%NDK_PATH%/build/cmake/android.toolchain.cmake  
SET CMAKE_PATH=%ANDROID_PATH%/cmake/3.22.1
  
REM *NOTE* Careful if you don't want rm -rf, I use it for testing purposes.  
del \F \S \Q %OUTPUT_DIR%
mkdir %OUTPUT_DIR%  
  
REM pushd doesn't seem to work ):<  
cd %OUTPUT_DIR%  
  
if not defined ORIGPATH set ORIGPATH=%PATH%  
SET PATH=%CMAKE_PATH%\bin;%ANDROID_PATH%\tools;%ANDROID_PATH%\platform-tools;%ORIGPATH%;%NDK_TOOLCHAIN%\bin;
  
%CMAKE_PATH%\bin\cmake.exe -GNinja -DCMAKE_TOOLCHAIN_FILE=%CMAKE_TOOLCHAIN%  -DANDROID_ABI="armeabi-v7a"  -DANDROID_NDK=%NDK_PATH% -DCMAKE_MAKE_PROGRAM=%CMAKE_PATH%\bin\ninja.exe -DCMAKE_BUILD_TYPE=Release  -DANDROID_NATIVE_API_LEVEL=24 -DANDROID_FORCE_ARM_BUILD=TRUE -DCMAKE_INSTALL_PREFIX=install -DANDROID_STL=c++_static -DCMAKE_CXX_FLAGS=-Wno-c++11-narrowing -DANDROID_TOOLCHAIN=clang ../
  
%CMAKE_PATH%\bin\cmake.exe --build .

cd ..

你可能感兴趣的:(C++,android,c++)