Apitrace的编译过程

apitrace是什么?

参见下面主页和github连接

http://apitrace.github.io/

https://github.com/apitrace/apitrace

apitrace并没有提供Linux系统的安装包deb/rpm/.run等,CentOS7的yum仓库也没有找到apitrace的安装包,只能自行编译

貌似Ubuntu上可以通过apt直接安装:

sudo apt install apitrace apitrace-gui

下载源码

git clone https://github.com/apitrace/apitrace.git

其中的第三方库thirdparty中的代码是用submodule的方式管理的,所以继续现在thirdparty中的源码:

git submodule update --init --recursive

注意:apitrace提示的submodule命令中有--depth,在我CentOS7平台报错,没有深究原因,去掉--depth就可以了

编译过程

编译平台是CentOS Linux release 7.9.2009 (Core)

cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=RelWithDebInfo

make -C build

遇到了几个编译错误

1. 貌似是C++版本过低造成的,在link的时候找不到regex_replace,下面代码换了一种写法,解决了问题

diff --git a/retrace/retrace_main.cpp b/retrace/retrace_main.cpp

index 3fa72e3..6a2cadf 100644

--- a/retrace/retrace_main.cpp

+++ b/retrace/retrace_main.cpp

@@ -865,7 +865,9 @@ adjustProcessName(const std::string &name)

 #ifndef _WIN32

     static const std::regex programFiles("/Program Files( \\(x86\\))?/", std::regex_constants::icase);

-    adjustedName = std::regex_replace(adjustedName, programFiles, "/opt/");

+    std::string tmpString("/opt/");

+    adjustedName = std::regex_replace(adjustedName, programFiles, tmpString);

 #endif


     if (endsWith(adjustedName, ".exe")) {

2. 解决了C++11新特性编译失败的问题

具体见另一篇文章:https://www.jianshu.com/p/f724360701fb

3. qapitrace Qt编译问题

问题报错如下:

CMake Warning at CMakeLists.txt:159 (find_package):

  By not providing "FindQt5.cmake" in CMAKE_MODULE_PATH this project has

  asked CMake to find a package configuration file provided by "Qt5", but

  CMake did not find one.

  Could not find a package configuration file provided by "Qt5" with any of

  the following names:

    Qt5Config.cmake

    qt5-config.cmake

  Add the installation prefix of "Qt5" to CMAKE_PREFIX_PATH or set "Qt5_DIR"

  to a directory containing one of the above files.  If "Qt5" provides a

  separate development package or SDK, be sure it has been installed.

问题是缺少了Qt库,首先要安装Qt,参考链接:https://liqiang.io/post/quick-install-qt5-in-centos-ff8ba74d,然后找到Qt目录:

[root@iZbp1197q2j1zlwv2hwun1Z /]# find . -name Qt5Config.cmake

./opt/Qt5.12.11/5.12.11/gcc_64/lib/cmake/Qt5/Qt5Config.cmake

./opt/Qt5.12.11/5.12.11/android_armv7/lib/cmake/Qt5/Qt5Config.cmake

./opt/Qt5.12.11/5.12.11/android_arm64_v8a/lib/cmake/Qt5/Qt5Config.cmake

./opt/Qt5.12.11/5.12.11/android_x86/lib/cmake/Qt5/Qt5Config.cmake

执行cmake命令:

cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_PREFIX_PATH=/opt/Qt5.12.11/5.12.11/gcc_64/lib/cmake/Qt5 -DENABLE_GUI=TRUE

后面的make编译命令不再赘述。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容