【问题标题】:How to build additional caffe tools?如何构建额外的 caffe 工具?
【发布时间】:2019-07-26 16:34:34
【问题描述】:

在 tools 文件夹下 caffe 库有一些工具作为单个 .cpp 文件 https://github.com/BVLC/caffe/tree/master/tools

我在这个文件夹下添加了自己的工具,可以通过cmake构建它。

当我添加额外的依赖项(json lib jsoncpp)时,构建在链接阶段失败的问题。

我已将 json lib .h、.cpp 文件放在 tools/json 文件夹下。

我的包括:

#include <iostream>
#include "opencv2/opencv.hpp"
#include "caffe/caffe.hpp"
#include "json/json.h"

我得到的错误,例如:

Undefined symbols for architecture x86_64:
  "Json::StyledWriter::write(Json::Value const&)", referenced from:
      image_list_processing(int, char**) in my_tool.cpp.o

所以问题是如何将 lib 添加到链接过程中?我应该修改https://github.com/BVLC/caffe/blob/master/tools/CMakeLists.txt 还是应该在tools/json/CMakeLists.txt 下添加单独的文件?

【问题讨论】:

    标签: makefile build cmake linker caffe


    【解决方案1】:

    这不是缺少.h 文件的错误。您需要将您的代码链接到共享对象(类似的libjsoncpp.so),以便您的代码访问(链接)已编译的 json 函数。

    将-L /path/to/libjson_folder 和-ljsoncpp 标志添加到您的makefile 的链接 阶段。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-10-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-02
    • 1970-01-01
    • 1970-01-01
    • 2014-12-23
    相关资源
    最近更新 更多