我使用 Pacman 命令安装了 OpenCV。但是我收到了数百行链接错误。我用命令编译了我的程序
gcc example.cpp -o example `pkg-config --cflags --libs opencv4`
链接错误的一小部分如下。
usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/../../../../lib/libopencv_viz.so: undefined reference to `vtkRenderingFreeType_AutoInit_Destruct()'
/usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/../../../../lib/libopencv_viz.so: undefined reference to `vtkInteractorStyle::StartTwoPointer()'
/usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/../../../../lib/libopencv_viz.so: undefined reference to `vtkInteractorStyle::EndZoom()'
/usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/../../../../lib/libopencv_viz.so: undefined reference to `vtkSmartPointerBase::operator=(vtkObjectBase*)'
/usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/../../../../lib/libopencv_viz.so: undefined reference to `vtkOStrStreamWrapper::freeze(int)'
/usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/../../../../lib/libopencv_viz.so: undefined reference to `vtkCamera::SetUserTransform(vtkHomogeneousTransform*)'
/usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/../../../../lib/libopencv_viz.so: undefined reference to `vtkCommand::UnRegister()'
/usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/../../../../lib/libopencv_viz.so: undefined reference to `vtkRenderer::New()'
/usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/../../../../lib/libopencv_viz.so: undefined reference to `vtkInteractorStyle::StartDolly()'
/usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/../../../../lib/libopencv_viz.so: undefined reference to `vtkRenderer::SetActiveCamera(vtkCamera*)'
/usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/../../../../lib/libopencv_viz.so: undefined reference to `vtkInteractorObserver::ReleaseFocus()'
/usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/../../../../lib/libopencv_viz.so: undefined reference to `vtkInteractorObserver::ComputeDisplayToWorld(double, double, double, double*)'
/usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/../../../../lib/libopencv_viz.so: undefined reference to `vtkAlgorithm::Update(vtkInformation*)'
/usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/../../../../lib/libopencv_viz.so: undefined reference to `vtkMatrix4x4::New()'