newbie dnn module problem with c++
Hello,
I compiled and installed opencv 3.4.1. When i write a small c++ program which reads in a torch model, it fails compiling with
CMakeFiles/nettest.dir/nettest.cpp.o: In function `main':
nettest.cpp:(.text+0x46): undefined reference to `cv::dnn::experimental_dnn_v4::readNetFromTorch(cv::String const&, bool)'
nettest.cpp:(.text+0x8b): undefined reference to `cv::dnn::experimental_dnn_v4::Net::~Net()'
nettest.cpp:(.text+0xc7): undefined reference to `cv::dnn::experimental_dnn_v4::Net::~Net()'
CMakeFiles/nettest.dir/nettest.cpp.o: In function `cv::String::String(char const*)':
nettest.cpp:(.text._ZN2cv6StringC2EPKc[_ZN2cv6StringC5EPKc]+0x54): undefined reference to `cv::String::allocate(unsigned long)'
CMakeFiles/nettest.dir/nettest.cpp.o: In function `cv::String::~String()':
nettest.cpp:(.text._ZN2cv6StringD2Ev[_ZN2cv6StringD5Ev]+0x14): undefined reference to `cv::String::deallocate()'
collect2: error: ld returned 1 exit status
CMakeFiles/nettest.dir/build.make:94: recipe for target 'nettest' failed
The code:
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/dnn.hpp"
#include <math.h>
#include <iostream>
using namespace cv;
using namespace std;
using namespace dnn;
int main( int argc, char** argv)
{
Net net = readNetFromTorch("openface.nn4.small2.v1.t7");
cout << "main" << endl;
return 0;
}
Did i made something wrong during compiling / installing opencv or is there a stupid mistake in my program? Thank you very much + Greetings, Holger
hi there, those are all linker errors. (missing opencv libs, your code is ok.)
could you add your CMakeLists.txt ? (there's probably something missing there)
Hello, here is my build file
you could also try to skip cmake, and simply compile it from the cmdline:
I tried invoking the compile directly with your arguments, its compiling! But when i execute it - i get:
I think i should taker some steps back and get open cv running correctly first before trying the dnn module. Thank you for helping my recognizing that my setup is xxx.