Home > Backend Development > C++ > Why Can't I Build My OpenCV 2.3 Project in Visual Studio 2010?

Why Can't I Build My OpenCV 2.3 Project in Visual Studio 2010?

Mary-Kate Olsen
Release: 2024-12-17 18:44:11
Original
729 people have browsed it

Why Can't I Build My OpenCV 2.3 Project in Visual Studio 2010?

Troubleshooting OpenCV 2.3 Setup for Visual Studio 2010

Issue:
Unable to build OpenCV 2.3 project with error 'LINK : fatal error LNK1104: cannot open file 'c:OpenCV2.3buildx86vc10lib.obj''.

Solution:

  1. Download and Extract OpenCV:

    • Download OpenCV-2.3.0-win-superpack.exe and extract it to a folder named OpenCV2.3.
    • Move the OpenCV2.3 folder to C:.
  2. Create New Project and Add Code:

    • Create a new Win32 Console Application project in Visual Studio 2010.
    • Add the following code to main.cpp:
    #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;
    }
    Copy after login
  3. Configure Include Directories:

    • Edit Additional Include Directories (Project Properties > C/C > General):

      • C:OpenCV2.3buildincludeopencv
      • C:OpenCV2.3buildincludeopencv2
      • C:OpenCV2.3buildinclude
  4. Configure Library Directories:

    • Edit Additional Library Directories (Project Properties > Linker > General):

      • C:OpenCV2.3buildx86vc10lib
  5. Add Library Dependencies:

    • Edit Additional Dependencies (Project Properties > Linker > Input):

      • opencv_core230.lib
      • opencv_highgui230.lib
  6. Add DLL Path to PATH Variable:

    • Modify the PATH environment variable to include:

      • ; C:OpenCV2.3buildx86vc10bin

Note:

  • Make sure to select "All Configurations" when configuring the project properties.
  • If you encounter any other errors, verify that OpenCV is properly installed and correctly configured in your system.

The above is the detailed content of Why Can't I Build My OpenCV 2.3 Project in Visual Studio 2010?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template