当我在OpenCV库中使用SSE代码时,我得到了一个未定义的引用'。
Ubuntu可信赖(试试x86和x86_64)。 来自apt-get的Opencv库。
#include <iostream>
#include <emmintrin.h>
#include <opencv2/opencv.hpp>
int main()
{
cv::VideoCapture cap("video.avi");
if (cap.isOpened() == false)
return 1;
cv::Mat mat;
cap >> mat;
if (!mat.data)
return 1;
_mm_set1_ps(0.f);
std::cout << "Done" << std::endl;
return 0;
}
g++ `pkg-config --cflags --libs opencv` main.cpp -msse2
修改
main.cpp :(。text + 0x42):未定义的引用
cv::VideoCapture::VideoCapture(std::string const&)' main.cpp:(.text+0x66): undefined reference to
cv :: VideoCapture :: isOpened()const&#39; main.cpp :(。text + 0x85):undefined 引用cv::VideoCapture::operator>>(cv::Mat&)' main.cpp:(.text+0xef): undefined reference to
cv :: VideoCapture :: ~VideoCapture()&#39; main.cpp :(。text + 0x111):undefined 引用cv::VideoCapture::~VideoCapture()' main.cpp:(.text+0x149): undefined reference to
cv :: VideoCapture :: ~VideoCapture()&#39; /tmp/cc0yDKh1.o:在功能上cv::Mat::~Mat()': main.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x2b): undefined reference to
CV :: fastFree(无效*)&#39; /tmp/cc0yDKh1.o:在功能上cv::Mat::release()': main.cpp:(.text._ZN2cv3Mat7releaseEv[_ZN2cv3Mat7releaseEv]+0x3b): undefined reference to
CV ::垫:: DEALLOCATE()&#39; collect2:错误:ld 返回1退出状态
你能帮我找到正确的gcc命令吗?
答案 0 :(得分:0)
事实上,这不是SSE问题。当我改变这样的编译命令时:
g++ -msse2 main.cpp `pkg-config --cflags --libs opencv`
它有效,我不知道为什么......