本文介绍了如何构建静态库并将它们链接到 linux 平台中的 c++ 项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从事一个文本分类项目,该项目很大并且不使用 bazel 作为其构建工具.我想将 tensorflow 集成到我的项目中,但我发现很难将我的构建工具更改为 bazel.所以我希望在 tensorflow 上构建静态库并将它们链接到我的项目中.有谁知道如何在 tensorflow 源代码上构建独立的静态库并将它们链接到现有的 C++ 项目中?非常感谢.

I am working on a text-classification project, which is big and doesn't use bazel as its build tool. I want to integrate tensorflow into my project, but I find it is hard to change my build tool to bazel. So I wish to build static libraries on tensorflow and link them into my project.Does anyone know how to build standalone static libraries on tensorflow source and link them in the existing c++ project? Thanks a lot.

推荐答案

TensorFlow 存储库有一些 Makefile 可用于构建静态库(请参阅 tensorflow/contrib/Makefile).

The TensorFlow repository has some Makefiles you can use to build a static library (see tensorflow/contrib/Makefile).

或者,您可以使用 bazel 构建 TensorFlow C++ 共享库,然后在您的应用程序中加载和使用共享库(bazel build -c opt//tensorflow:libtensorflow_cc.so).不幸的是,bazel 还不能生成静态库(#1920).

Alternatively, you could use bazel to build the TensorFlow C++ shared library and then load and use the shared library in your application (bazel build -c opt //tensorflow:libtensorflow_cc.so). Unfortunately, bazel can't yet produce a static library (#1920).

希望有所帮助.

这篇关于如何构建静态库并将它们链接到 linux 平台中的 c++ 项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 09:51