mrgloom
mrgloom

Reputation: 21632

How to build additional caffe tools?

Under tools folder caffe library have some tools as single .cpp files https://github.com/BVLC/caffe/tree/master/tools

I have added my own tool under this folder and can build it via cmake.

The problem that when I have added additional dependency (json lib jsoncpp) build fails at linking phase.

I have put json lib .h, .cpp files under tools/json folder.

My includes:

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

Error that I get, like:

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

So the question is how to add lib to linking process? Should I modify https://github.com/BVLC/caffe/blob/master/tools/CMakeLists.txt or maybe I should add separate file under tools/json/CMakeLists.txt?

Upvotes: 1

Views: 74

Answers (1)

Shai
Shai

Reputation: 114816

This is not an error of missing .h file. You need to link your code to the shared object (libjsoncpp.so of similar) for your code to access (link) compiled json functions.

add -L /path/to/libjson_folder and -ljsoncpp flags to the linking stage of your makefile.

Upvotes: 1

Related Questions