使用 OpenCV 库编译 SSE 代码
Compilation SSE code using OpenCV libraries
当我将SSE代码与OpenCV库一起使用时,我得到了一个'未定义的引用'。
Ubuntu trusty (在 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' main.cpp:(.text+0x85): undefined 引用cv::VideoCapture::operator>>(cv::Mat&)' main.cpp:(.text+0xef): undefined reference to
cv::VideoCapture::~VideoCapture()' main.cpp:(.text+0x111): undefined 参考cv::VideoCapture::~VideoCapture()' main.cpp:(.text+0x149): undefined reference to
cv::VideoCapture::~VideoCapture()'/tmp/cc0yDKh1.o: In functioncv::Mat::~Mat()': main.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x2b): undefined reference to
cv::fastFree(void*)'/tmp/cc0yDKh1.o: In functioncv::Mat::release()': main.cpp:(.text._ZN2cv3Mat7releaseEv[_ZN2cv3Mat7releaseEv]+0x3b): undefined reference to
cv::Mat::d eallocate()' collect2: error: ld 返回 1 个退出状态
你能帮我找到正确的 gcc 命令吗?
事实上,这不是 SSE 问题。当我像这样更改编译命令时:
g++ -msse2 main.cpp `pkg-config --cflags --libs opencv`
它有效,我不知道为什么...
- C++我的数学有什么问题,为什么我的代码不能正确循环
- 代码在main()中运行,但在函数中出现错误
- 在VS代码中交叉编译Windows与Linux上的MinGW的SDL程序
- 编译包含字符串的代码时遇到问题
- 我在c++代码中生成了一个运行时#3异常
- 如何在linux终端中同时编译和运行c++代码
- 如何检查编译的代码是否使用了 SSE 和 AVX 指令?
- SIMD/SSE代码在Windows 8上清楚地运行在Windows 7和Linux上
- 为什么我的SSE代码比本机C++代码慢
- C /SSE代码的有效霓虹灯内在
- SSE 向量的对齐和未对齐加载和存储 - 如何减少代码重复
- 当函数参数是常量引用临时或按值复制的临时时,为什么 MSVC 优化会破坏 SSE 代码
- 如何使用 SSE 或 GLSL 优化"u[0]*v[0] + u[2]*v[2]"代码行
- 如何将此代码重写为 sse 内部函数
- 使用 OpenCV 库编译 SSE 代码
- 将SSE内部函数转换为可读的C/C++代码
- 将SSE矩阵矢量乘法代码转换为AVX
- 在托管代码中调用SSE代码(对齐)
- 确定eigen是否为SSE指令优化了代码
- 您将如何编写可能优化为一条SSE指令的无符号加法代码