已编译 opencv 程序,但不执行 ( c++ )

opencv program compiled, but it does not execute ( c++ )

我在网上找到了下面的c++程序,

#include <opencv2/opencv.hpp>
using namespace cv;

int main(void) {

    // Read image in GrayScale mode
    Mat image = imread("emily.jpg", 0);

    // Save grayscale image
    imwrite("emilyGray.jpg", image);

    // To display the image
    imshow("Grayscale Image", image);
    waitKey(0);

    return 0;
}

然后我用下面的代码编译了上面的程序,

g++ opencv1.cpp -o opencv1.exe -IC:\opencv\build\install\include -LC:\opencv\build\install\x64\mingw\lib -lopencv_calib3d452 -lopencv_core452 -lopencv_highgui452 -lopencv_imgcodecs452

在 运行 opencv1.exe 之后,没有变化,没有创建图像。

注意:- 我正在使用 mingw 进行编译,我的 opencv 是用 mingw 和 cmake 构建的。

其实我用mingw32-make构建opencv后并没有设置opencv dll的路径

将环境变量的 PATH 变量设置为 C:\opencv\build\bin 后,我可以看到输出。

此致