OAID / FaceDetection

C++ project to implement MTCNN, a perfect face detect algorithm, on different DL frameworks. The most popular frameworks: caffe/mxnet/tensorflow, are all suppported now
Apache License 2.0
272 stars 108 forks source link

make error with tensorflow #8

Closed flankechen closed 6 years ago

flankechen commented 6 years ago

I am working with tensorflow and success in bazel build. I do have libtensorflow_framework.so libtensorflow.so in /usr/local/lib/ and I verify this with a toy .c file with

#include <stdio.h>
#include <tensorflow/c/c_api.h>

int main() {
  printf(“Hello from TensorFlow C library version %s\n”, TF_Version());
  return 0;
}

and gcc -I/usr/local/include -L/usr/local/lib hello_tf.c -ltensorflow and it runs as expected

but in this project, I got these errors like:

g++ -Wall -O2 -ggdb -std=c++11 -I/home/sensetime/miaospace/FaceDetection/include pkg-config --cflags opencv -I/usr/local//include -c test.cpp -o test.o make[1]: Entering directory /home/sensetime/miaospace/FaceDetection/libmtcnn' g++ -fpic -shared -Wall -O2 -ggdb -std=c++11 -I/home/sensetime/miaospace/FaceDetection/includepkg-config --cflags opencv-I/usr/local//include -c mtcnn.cpp -o mtcnn.os g++ -fpic -shared -Wall -O2 -ggdb -std=c++11 -I/home/sensetime/miaospace/FaceDetection/includepkg-config --cflags opencv-I/usr/local//include -c comm_lib.cpp -o comm_lib.os g++ -fpic -shared -Wall -O2 -ggdb -std=c++11 -I/home/sensetime/miaospace/FaceDetection/includepkg-config --cflags opencv-I/usr/local//include -c utils.cpp -o utils.os g++ -fpic -shared -Wall -O2 -ggdb -std=c++11 -I/home/sensetime/miaospace/FaceDetection/includepkg-config --cflags opencv-I/usr/local//include -c tensorflow_mtcnn.cpp -o tensorflow_mtcnn.os g++ -fpic -shared -o libmtcnn.so mtcnn.os comm_lib.os utils.os tensorflow_mtcnn.os g++ -Wall -O2 -ggdb -std=c++11 -I/home/sensetime/miaospace/FaceDetection/includepkg-config --cflags opencv-I/usr/local//include -c mtcnn.cpp -o mtcnn.o g++ -Wall -O2 -ggdb -std=c++11 -I/home/sensetime/miaospace/FaceDetection/includepkg-config --cflags opencv-I/usr/local//include -c comm_lib.cpp -o comm_lib.o g++ -Wall -O2 -ggdb -std=c++11 -I/home/sensetime/miaospace/FaceDetection/includepkg-config --cflags opencv-I/usr/local//include -c utils.cpp -o utils.o g++ -Wall -O2 -ggdb -std=c++11 -I/home/sensetime/miaospace/FaceDetection/includepkg-config --cflags opencv-I/usr/local//include -c tensorflow_mtcnn.cpp -o tensorflow_mtcnn.o ar -rcv libmtcnn.a mtcnn.o comm_lib.o utils.o tensorflow_mtcnn.o a - mtcnn.o a - comm_lib.o a - utils.o a - tensorflow_mtcnn.o make[1]: Leaving directory/home/sensetime/miaospace/FaceDetection/libmtcnn' g++ -Wall -O2 -ggdb -std=c++11 -I/home/sensetime/miaospace/FaceDetection/include pkg-config --cflags opencv -I/usr/local//include test.o -o test -L/home/sensetime/miaospace/FaceDetection/libmtcnn -lmtcnn pkg-config --libs opencv pkg-config --libs computelibrary Package computelibrary was not found in the pkg-config search path. Perhaps you should add the directory containing computelibrary.pc' to the PKG_CONFIG_PATH environment variable No package 'computelibrary' found /home/sensetime/miaospace/FaceDetection/libmtcnn/libmtcnn.so: undefined reference toTF_ImportGraphDefOptionsSetPrefix' /home/sensetime/miaospace/FaceDetection/libmtcnn/libmtcnn.so: undefined reference to TF_NewStatus' /home/sensetime/miaospace/FaceDetection/libmtcnn/libmtcnn.so: undefined reference toTF_CloseSession' /home/sensetime/miaospace/FaceDetection/libmtcnn/libmtcnn.so: undefined reference to TF_NewImportGraphDefOptions' /home/sensetime/miaospace/FaceDetection/libmtcnn/libmtcnn.so: undefined reference toTF_TensorData' /home/sensetime/miaospace/FaceDetection/libmtcnn/libmtcnn.so: undefined reference to TF_DeleteTensor' /home/sensetime/miaospace/FaceDetection/libmtcnn/libmtcnn.so: undefined reference toTF_SessionRun' /home/sensetime/miaospace/FaceDetection/libmtcnn/libmtcnn.so: undefined reference to TF_NewTensor' /home/sensetime/miaospace/FaceDetection/libmtcnn/libmtcnn.so: undefined reference toTF_DeleteStatus' /home/sensetime/miaospace/FaceDetection/libmtcnn/libmtcnn.so: undefined reference to TF_GetCode' /home/sensetime/miaospace/FaceDetection/libmtcnn/libmtcnn.so: undefined reference toTF_Dim' /home/sensetime/miaospace/FaceDetection/libmtcnn/libmtcnn.so: undefined reference to TF_NewSessionOptions' /home/sensetime/miaospace/FaceDetection/libmtcnn/libmtcnn.so: undefined reference toTF_GraphImportGraphDef' /home/sensetime/miaospace/FaceDetection/libmtcnn/libmtcnn.so: undefined reference to TF_Message' /home/sensetime/miaospace/FaceDetection/libmtcnn/libmtcnn.so: undefined reference toTF_DeleteGraph' /home/sensetime/miaospace/FaceDetection/libmtcnn/libmtcnn.so: undefined reference to TF_GraphOperationByName' /home/sensetime/miaospace/FaceDetection/libmtcnn/libmtcnn.so: undefined reference toTF_NewGraph' /home/sensetime/miaospace/FaceDetection/libmtcnn/libmtcnn.so: undefined reference to TF_DeleteSession' /home/sensetime/miaospace/FaceDetection/libmtcnn/libmtcnn.so: undefined reference toTF_NewSession' collect2: error: ld returned 1 exit status make: *** [test] Error 1

I think there is something missing in linking tensorflow in test.o

ybao2016 commented 6 years ago

see my patch on makefile.mk below. It solves my problem on my ubuntu16.04

@@ -12,9 +12,9 @@ CXXFLAGS += -I$(TOPDIR)/include

ARFLAGS = -rcv

-CAFFE_ON = 1 +CAFFE_ON = 0 MXNET_ON = 0 -TF_ON = 0 +TF_ON = 1

MTCNN_LDFLAGS = -L$(MTCNNLIBDIR) -Wl,--whole-archive -lmtcnn -Wl,--no-whole-archive

LDFLAGS += -L$(MTCNNLIBDIR) -lmtcnn @@ -42,14 +42,17 @@ endif

tensorflow settings

ifeq ($(TF_ON), 1)

flankechen commented 6 years ago

@ybao2016 thanks for your reply, in face, I switch to this repo and it works .

flankechen commented 6 years ago

@ybao2016 thanks for your reply, in face, I switch to this repo and it works .

kapildevkumara commented 4 years ago

Thanks. the above fix clears the error. I also added export MTCNNLIBDIR=~/FaceDetection/libmtcnn But this project is clean for Tensorflow.