I want to perform some preprocessing, with opencv, on an image which will be fed to a tensorflow model.
The preprocessing part reads in a .png
file, the code works as a standalone program, but I want to use it inside the program that runs the tensorflow model, so I generated an object file as below. The program for preprocessing works perfectly as standalone.
g++ -std=c++11 preProcess.cpp -I/home/dpk/anaconda2/include/libpng16 -I/usr/local/include/opencv2 -L/home/dpk/anaconda2/lib -lpng16 -lopencv_highgui -lopencv_imgcodecs -lopencv_imgproc -lopencv_core -c
The tensorflow program, Inference.cc
was compiled as below
g++ -std=c++11 preProcess.o Inference.cc -I/home/dpk/anaconda2/include/libpng16 -I/usr/local/include/opencv -I/usr/local/include/opencv2 -I/usr/local/include/tf -I/usr/local/include/eigen3 -I/usr/local/include/tf/bazel-genfiles -g -Wall -D_DEBUG -Wshadow -Wno-sign-compare -w -L/usr/local/lib/libtensorflow_cc -L/home/dpk/anaconda2/lib -lpng16 -lopencv_highgui -lopencv_imgcodecs -lopencv_imgproc -lopencv_flann -lopencv_core `pkg-config --cflags --libs protobuf` -ltensorflow_cc -o inference
This throws the following error
/usr/local/lib/libtensorflow_cc.so: undefined reference to `std::thread::_State::~_State()@GLIBCXX_3.4.22'
/usr/local/lib/libtensorflow_cc.so: undefined reference to `std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)())@GLIBCXX_3.4.22'
/usr/local/lib/libtensorflow_cc.so: undefined reference to `typeinfo for std::thread::_State@GLIBCXX_3.4.22'
This error seems to be caused by linking -L/home/dpk/anaconda2/lib
, because compilation goes smoothly when I don't link that folder , but then the program fails to read .png
files. Hence it appears that, that folder is necessary for handling .png
.
I need my program to read .png
files as well as run the tensorflow model. How can I make both of them work?