Home >Backend Development >C++ >How to Resolve the 'LNK1104: cannot open file 'lib.obj'' Error When Setting Up OpenCV 2.3 with Visual Studio 2010?

How to Resolve the 'LNK1104: cannot open file 'lib.obj'' Error When Setting Up OpenCV 2.3 with Visual Studio 2010?

DDD
DDDOriginal
2024-12-15 12:59:18821browse

How to Resolve the

Troubleshooting OpenCv-2.3 Setup for Visual Studio 2010

While integrating OpenCv 2.3 with Visual Studio 2010 Express, you may encounter the fatal error "LINK : fatal error LNK1104: cannot open file 'c:OpenCV2.3buildx86vc10lib.obj'." This occurs because there is no lib.obj in the OpenCV folders, often due to skipping the CMake compilation step.

Resolution:

To alleviate this issue, follow these steps:

  1. Add Include Directories:

    • Configuration Properties > C/C > General > Additional Include Directories:

      • C:OpenCV2.3buildincludeopencv
      • C:OpenCV2.3buildincludeopencv2
      • C:OpenCV2.3buildinclude
  2. Add Library Directories:

    • Configuration Properties > Linker > General > Additional Library Directories:

      • C:OpenCV2.3buildx86vc9lib
  3. Add Libraries:

    • Configuration Properties > Linker > Input:

      • opencv_core230.lib
      • opencv_highgui230.lib
  4. Modify PATH Variable:

    • Append the OpenCV DLL location to the PATH environment variable:

      • ;C:OpenCV2.3buildx86vc9bin
  5. Build Project:

    • Press F7 to compile.
  6. Run Application:

    • Ensure OpenCV's DLLs are accessible by modifying the PATH variable.
  7. Execute Code:

    • Run the code sample provided:

      #include <stdio.h>
      #include <cv.h>
      #include <highgui.h>
      
      int main(int argc, char* argv[])
      {
        if (argc < 2)
        {
          printf("Usage: ./opencv_hello <file.png>\n");
          return -1;
        }
        IplImage* img = cvLoadImage(argv[1], CV_LOAD_IMAGE_UNCHANGED);
        if (!img)
        {
          return -1;
        }
        cvNamedWindow("display", CV_WINDOW_AUTOSIZE);
        cvShowImage("display", img);
        cvWaitKey(0);
        return 0;
      }

The above is the detailed content of How to Resolve the 'LNK1104: cannot open file 'lib.obj'' Error When Setting Up OpenCV 2.3 with Visual Studio 2010?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn