I'm on Ubuntu Trusty and I'm building the following code with this command. I'm new to clang and I could use help debugging these errors. The cpp and hpp files these C bindings are from compile fine. I copied the headers from those files into the below file I have listed here, w.cpp
clang -std=c++11 w.cpp -o w `pkg-config --cflags --libs opencv`
Here are the errors:
/usr/bin/ld: /tmp/w-2a90f4.o: undefined reference to
symbol '_ZNSt8ios_base4InitD1Ev@@GLIBCXX_3.4'
//usr/lib/x86_64-linux-gnu/libstdc++.so.6: error adding
symbols: DSO missing from command line
clang: error: linker command failed with exit code 1
(use -v to see invocation)
Here is the contents of w.cpp. I'm trying to benchmark code using clang.
#include <opencv2/c/mat.hpp>
#include <opencv2/c/opencv_generated.hpp>
using namespace cv;
using namespace std;
using namespace flann;
using namespace cvflann;
void cv_delete(char* self) {
delete self;
}
Mat* cv_create_Mat() {
return new Mat();
}
BFMatcher* cv_create_BFMatcher(int normType, bool crossCheck) {
return new BFMatcher(normType, crossCheck);
}
int main () {
for( int a = 1; a < 20; a++)
{
Mat a = &cv_create_Mat();
cv_delete(a);
}
}
I had the same error using gcc instead of g++, I believe you must use clang++
clang++ -std=c++11 w.cpp -o w `pkg-config --cflags --libs opencv`
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With